Onion Omega2 Pro is available…

The Omega2 Pro IoT computer is the next generation of Onion’s Linux-based, WiFi development board and the most powerful IoT computer they have made yet.

It is a standalone device – the processor, memory, gigabytes of storage, and Wi-Fi are all built-in, and it’s smaller than a breadboard, making it easier than ever to build connected hardware applications.

Specs:

  • Processor: 580 MHz MIPS CPU
  • Memory: 128 MB RAM and 384 MB flash swap file
  • Storage: 8 GB (no SD Card required)
  • Connectivity: 2.4 GHz b/g/n Wi-Fi
  • Operating System: OpenWRT 18.06 Linux
  • Battery Support: LiPo battery management & JST-PH battery connector
  • Antenna: 2 dBi directional chip antenna & U.FL connector for external antenna
  • Dimensions: 73 mm x 44 mm
  • Ethernet
  • Battery Manager for Portability and Back-up
  • Commandline Access via an on-board USB-to-serial chip or through the local network using SSH
  • Full-color Notification LED

On top of that, it’s compatible with the existing ecosystem of plug-and-play Omega2 expansions to add functionality.

Onion Omega2 Pro is available…

Python3 on Onion Omega2(+)

The official end-of-life for Python 2 is rapidly approaching, so you should start using Python 3 for new applications on Onion Omega2(+) too.

You will find important information in the post “MODERNIZE YOUR DEVELOPMENT WITH PYTHON3“.

After an update we can list the available Python3 packages and with an additional grep exp the modules required for using Onion Omega Expansion boards.

# opkg update
# opkg list | grep python3
...
# opkg list | grep python3 | grep exp
python3-adc-exp - 0.3-2 - Python3 module to interact with Onion ADC Expansion
python3-oled-exp - 0.9-1 - Python3 module to control the Onion OLED Expansion
python3-omega-expansion - 0.9-1 - Setup for OmegaExpansion Python3 Package
python3-pwm-exp - 0.9-1 - Python3 module to control the Onion PWM Expansion
python3-relay-exp - 0.9-1 - Python3 module to control the Onion Relay Expansion

For my program sample here I need the OLED expansion and have to install it:

# opkg install python3-omega-expansion python3-oled-exp

The program getTemp.py reads a waterproof DS18B20 temperature sensor measuring water temperature one meter below the waterline. The result will be displayed on OLED display. Important here are the Python3 commands

#!/usr/bin/python3

# Get temperatur data from DS18B20
# Source: https://bigl.es/ds18b20-temperature-sensor-with-python-raspberry-pi/
# Install library: pip3 install w1thermsensor

import time, os
from w1thermsensor import W1ThermSensor
from OmegaExpansion import oledExp

print('Measuring temperature by DS18B20 sensor...')

status = oledExp.driverInit()
if (status != 0):
    print('OLED init failed')
    exit()
status = oledExp.setTextColumns()
sensor = W1ThermSensor()
while True:
    temperature = sensor.get_temperature()
    print("DS18B20 temperature is {:2.1f} *C".format(temperature))
    status = oledExp.setCursor(6,0)
    status |= oledExp.write('DS18B20: '+format(temperature, '.1f')+' *C')
    if (status != 0):
        print('OLED output failed')
        break

time.sleep(1)

 

The Openweathermap app replaces the Wunderground app as explained in my last post. Here is the Shell script oled.sh controlling the OLED.

#!/bin/sh -e

echo "Initialize OLED..."
oled-exp -i
oled-exp -c

echo "Draw logo..."
oled-exp draw /root/onion.lcd
sleep 1
oled-exp -c

echo "Show date & time..."
d=`date +%d-%m-%Y`
t=`date +%H:%M`
oled-exp write $d 
oled-exp cursor 0,11 write $t

oled-exp cursor 2,0 write "Temp:"
read T < /home/TEMP
oled-exp cursor 2,7 write $T
oled-exp cursor 2,12 write "*C"

oled-exp cursor 3,0 write "Humi:"
read H < /home/HUMI
oled-exp cursor 3,7 write $H 
oled-exp cursor 3,10 write "% r.H."

All program samples are saved on Github.

Data from both applications (./weather.sh & ./getTemp.py) will be displayed on the OLED as shown below.

oled

 

Python3 on Onion Omega2(+)

Replace Weather Underground by OpenWeatherMap

Due to the end of service for Weather Underground API you can replace this service by OpenWeatherMap.

You have to register there and afterwards you can use Current weather data as a free service after subscription.

Access weather data for your location by calling

http://api.openweathermap.org/data/2.5/weather?q={your location}&APPID={your API key}

for me this was, for example:

http://api.openweathermap.org/data/2.5/weather?q=Altendorf,CH&APPID=eaxxxxxyyyyyyyyy58

and I got the following answer after formatting by JSON Pretty Print:

{
  "coord": {
    "lon": 8.83,
    "lat": 47.19
  },
  "weather": [
    {
      "id": 701,
      "main": "Mist",
      "description": "mist",
      "icon": "50n"
    }
  ],
  "base": "stations",
  "main": {
    "temp": 279.65,
    "pressure": 1021,
    "humidity": 93,
    "temp_min": 279.15,
    "temp_max": 280.15
  },
  "wind": {
    "speed": 0.32,
    "deg": 82.0013
  },
  "clouds": {
    "all": 75
  },
  "dt": 1544034000,
  "sys": {
    "type": 1,
    "id": 6932,
    "message": 0.0022,
    "country": "CH",
    "sunrise": 1543992940,
    "sunset": 1544024117
  },
  "id": 2661776,
  "name": "Altendorf",
  "cod": 200
}

Try it and you can replace the Weather Underground API.

Replace Weather Underground by OpenWeatherMap

End of Service for the Weather Underground API

In a post from January 2017 I wrote about getting weather data from Weather Underground (wunderground).

The used Weather Underground API will be out of service end of this year. For further information see this link, please.

Your applications using the Weather Undergound API will get no data afterwards. You have to change the service.

I will show how in a next post.

End of Service for the Weather Underground API

SparkFun MicroView as serial display

I added a SparkFun MicroView display to the Omega2+ to show temperature and humidity from Weather Underground. The display text here is in German but can changed.

serialdisplay

The MicroView USB programmer serves as programmer for the Arduino inside MicroView and as serial interface between Omega2+ USB and MicroView TX/RX.

The Arduino program SerialDisplay.ino waits for a telegram containing a start character, the temperature as floating point number, and the humidity as integer.

To control the serial interface /dev/ttyUSB0 at Omega2+ we have to install stty by opkg install coreutils-stty. The Shell script oled.sh sends the data from Omega2+ to MicroView.

During serial communication MicroView is controlled by DTR (The bootloader will be activated). Therefore, DTR must be disabled in this case. I did not find a solution by stty. A simple way is to connect TX, RX, GND and VCC between MicroView and MicroView programmer only. This way the RST line is not affected during serial communication.

All script including the Arduino sketch are saved at Github as usual.

 

 

SparkFun MicroView as serial display

Is your IoT node running?

If you test a new IoT node (or a Linux device in general) it is important to get some information whether the node runs stable or have problems.

The command uptime returns the time elapsed since last boot and some other information.

root@Omega-B2BB:/home# uptime
 23:34:53 up 4 days, 13:56, load average: 0.00, 0.00, 0.00

The uptime command gives a one line display of the following information.

  • The current time (23:34:53)
  • How long the system has been running (up 4 days)
  • The system load averages for the past 1, 5, and 15 minutes (0.00, 0.00, 0.00)

Here the Omega2+ has not a lot to do.

It’s not allways possible to contact that node directly for monitoring. To send the uptime result as a message is a good way to get this info.

My preferred way is to use Pushover messages but I had problem with sending the data by cURL. I have to wait for an answer from Onion’s community because this worked with an older firmware version.

But, to get this info yet I use Twitter direct messages. IFTTT acts as a gateway to twitter.ifttt

 

I use the Maker event to trigger sending a direct message to myself.

The configuration is quite simple. The event is named Uptime, what else?

After that we can specify the message content. I will send only one value with the complete uptime message inside.

To send the message from Omega2+ (or any other Linux device) I use a POST web request sent by cURL. The complete Shell script monitoring_update.sh looks as follows:

#!/bin/sh

uptime > UPT
MSG=`cat UPT`
echo -n Uptime:
echo "$MSG"

# Send data as Twitter direct message via IFTTT
curl --data "value1=$MSG" \
  https://maker.ifttt.com/trigger/Uptime/with/key/dy0QeH-N3Ezfa4Ilst-r4F

 

You can find the script at Github.

I placed the script in a crontab for calling it each hour. There is a second script which calls weather data each 15 minutes.

root@Omega-B2BB:/home# crontab -l
#
0 */1 * * * /home/monitoring_uptime.sh
*/15 * * * * /home/weather.sh
#

You can see the direct messages sent from my Omega2+ on my mobile phone.

tweet

 

 

Is your IoT node running?