Category: IoT

One of my apps does not start after a restart. I changed several things on the Node-Red app and i think the restart will be a good idea.

On the logs view there was no good messages to see what is happening with Node-Red

So i start the terminal and go to use IBM cloud CLI

to get the app log just logon and type ibmcloud cf logs [appname] > log.txt

I saw the following messages

[CELL/0] OUT Cell a64da35a-93fb-4f76-abd8-219869380b84 creating container for instance 6b30e79e-2853-4199-4c3e-1cc0
2019-09-04T13:54:47.36-0300 [CELL/0] OUT Cell a64da35a-93fb-4f76-abd8-219869380b84 successfully created container for instance 6b30e79e-2853-4199-4c3e-1cc0
2019-09-04T13:54:55.45-0300 [CELL/0] OUT Starting health monitoring of container
2019-09-04T13:55:06.64-0300 [APP/PROC/WEB/0] OUT > [email protected] start /home/vcap/app
2019-09-04T13:55:06.64-0300 [APP/PROC/WEB/0] OUT > node –max-old-space-size=180 index.js –settings ./bluemix-settings.js -v
2019-09-04T13:55:06.98-0300 [APP/PROC/WEB/0] OUT 4 Sep 16:55:06 – Starting Node-RED on IBM Cloud bootstrap
2019-09-04T13:55:06.98-0300 [APP/PROC/WEB/0] OUT 4 Sep 16:55:06 – Loading bluemix-settings.js
2019-09-04T13:55:07.18-0300 [APP/PROC/WEB/0] OUT 4 Sep 16:55:07 – Failed to find Cloudant service: /^IoT-Cool.cloudantNoSQLDB/
2019-09-04T13:55:07.19-0300 [APP/PROC/WEB/0] ERR module.js:478
2019-09-04T13:55:07.19-0300 [APP/PROC/WEB/0] ERR throw err;
2019-09-04T13:55:07.19-0300 [APP/PROC/WEB/0] ERR ^
2019-09-04T13:55:07.19-0300 [APP/PROC/WEB/0] ERR Error: Cannot find module ‘./node_modules/node-red/red/runtime/storage/localfilesystem’

Node-Red was unable  connect to Cloudant. But not was changed on Cloudant side.

I changed the Title of the app to another name before the restart, that was the cause of the problem.

I think there is a relation between the APP name and the Cloudant Service linked to the app

After i change the app name to the old one, Node-Red starts again.

 

 

 

IoT Uncategorized

Rules are key elements for an IoT solution. Using rules you can trigger an action or send an alert any kind of notification.
IBM update his platform and now you can create rules using a graphical interface.

The key part of a rule is the expression that will be evaluate to true or false.  The expression language are built using JSONata.
JSONata is a lightweight query and transformation language for JSON data.

The point is that IBM are using JSONata v1.4x. and the current version of JSONata is v1.6.5. The versions have lots of difference.
Yesterday i was writing a rule to get the hour for an event. If you are using v1.6.5 you can use the function $fromMilllis with picture.
$fromMillis(1510067557121, ‘[H01]’, ‘-0500’) => “10”
But Watson IoT are using v1.4x  and $fromMillis doesn’t have the picture implemented. The only way i found is to manipulate strings and i got the following expression:

$number($substring($fromMillis($state.datahora),11,1)) < 1 and $number($substring($fromMillis($state.datahora),12,1)) < 3 ? $number($substring($fromMillis($state.datahora),12,1))+24-3 : $number($substring($fromMillis($state.datahora),11,1))*10+ $number($substring($fromMillis($state.datahora),12,1))-3
$state.datahora returns an epoch timestamp.
This expression returns the hour on my timezone (-3). If anyone have a more elegant solution post on comments. I know my solution can’t be the better one, but it works.

IoT

This month i am creating a Course about AI & IoT   (AI & IoT Fundamentals).

The course are about AI and IoT in general but i will use IBM Watson APIs, IBM Watson IoT and off course Node-Red and Raspberry Pi to make the excersices.

The course is 15 hours long (lots off video) plus the exercises.

Using the Keynote to generate de videos is fine but when i export the video the only option is M4V type.  To convert the videos i am usin FFmpeg.

1 – Install FFmpeg brew install ffmpeg

2 – Convert to mp4 using ffmpeg -i input.m4v out.mp4

3 – Convert to webm ffmpeg -i input.m4v output.webm

 

AI IoT MAC

This is the first public beta release of Node-RED 1.0.

The changes in this release are mostly focused on the editor – and there are some significant changes in there.

More info here

Installing the beta

If you want to try out the beta, you will need specify [email protected] when you use npm to update. Without the @next you’ll still get 0.20.x.

So on a Pi you’d do:

sudo npm install -g --unsafe-perm [email protected]

IoT

Connect an Arduino Board to a computer is a easy task right? 99% yes.  My Arduino Nano Board arrived last week and i only have time to play with this board on the last weekend.

When i try to upload a program to the board i got the following:

Arduino: 1.8.8 (Mac OS X), Board: “Arduino Nano, ATmega328P”

Sketch uses 444 bytes (1%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x50
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x72
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x6f
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x67
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x72
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x61
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x6d
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x61
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x73
An error occurred while uploading the sketch

I tried on a Windows and Linux coputer with no luck but the same problem.

I read lot’s off posts in Arduino forums, some problems with MAC OS Sierra, i setup drivers  and nothing.

Today i found a solution :

Tools > Board > ATmega328P (Old Bootloader) on Arduino IDE.

The forum post https://forum.arduino.cc/index.php?topic=530807.0 has more solutions for another problem. I think is because Arduino has several clones.

 

IoT

Every sensor has it’s own kind off codification
The message from the device is like this one:

{"time": "1551285775",
"deviceType": "deviceType",
"device": "xyzabcd",
"duplicate": "false",
"snr": "30.00",
"rssi": "-128.00",
"avgSnr": "19.39",
"station": "300C",
"lat": "-20.0",
"lng": "-44.0",
"seqNumber": "497",
"data": "1a24183c3801" }

The measurement are encoded on data string, a sequence of 6 bytes.
I read the sensor manual and the temperature are usin the last 4 bytes

To get the temperature value i wrote the following:

var dados = msg.payload.data //get the data value “1a24183c3801”
var v1 = dados.substring(10,11)+dados.substring(11,12)+dados.substring(8,9)+dados.substring(9,10) //get the 4 values as in the device manual
For example the value will be “0138”
The temperature will be temp = parseInt(v1,16)/100
Using the value 0138 the result is 3,12 Degrees Celsius
But if the temperatue is negative you need to test if the first bit of the meesage is 1 and use

temp = parseInt((~parseInt(v1,16) +1 >>> 0).toString(2).substring(16,32),2)/100 * -1

The formula code on the line above use twos complement format, get the last 16 bits and then convert to a decimal value

IoT

Today i am working on a batch operation registering several sensors on IBM Watson IoT.

Using curl you need to encode de API KEY and API TOKEN

It easy using the MAC terminal console

To encode just type on terminal: echo -n ‘user:password’ | base64
the result is —> dXNlcjpwYXNzd29yZA==

To decode just type: echo ‘dXNlcjpwYXNzd29yZA==’ | base64 -D
the result is —> user:password

IoT

I setup the connection to cloudant service to store historical data of my IoT devices. When i click “done” an pop up window appears asking to authorize the connection to Cloudant Service. I confirm to authorize and i get the message 502 Bad Gateway: Registered endpoint failed to handle the request. and i can’t store iot device data on cloudant. I tried several times.

I search a lot about this error message with no luck .  To solve the problem erase all IBM cookies from you browser and restart it.

Cloud IoT