What: test
When: December 13, 2016 at 06:21PM
Extra Data: 256, 25091, 3240,
Notes on problems and solutions found while developing and goofing around, only technical and science stuff, no commercial pitchs, preaching or thought-leader crap, just hands-on stuff.
Tuesday, 13 December 2016
This is a "test" of my 6LoWPAN connected device
What: test
When: December 13, 2016 at 06:21PM
Extra Data: 0, -31582, 3244,
When: December 13, 2016 at 06:21PM
Extra Data: 0, -31582, 3244,
This is a "test" of my 6LoWPAN connected device
What: test
When: December 13, 2016 at 06:21PM
Extra Data: 256, 24834, 3240,
When: December 13, 2016 at 06:21PM
Extra Data: 256, 24834, 3240,
Sunday, 18 October 2015
A simple WiFi power cord switch with the OLIMEX ESP8266 evaluation board
![]() |
| Image taken from OLIMEX website |
After some months of having a couple of OLIMEX ESP8266 evaluation boards lying around in my office desk, I decided to jump in the ESP8266 hype train and see by myself how this US$5 WiFi module changed the maker landscape.
I was not dissapointed.
The ESP2866
The ESP8266 is a highly integrated SoC (System on Chip) which includes Xtensa LX106 core processor, RAM, a RF front end and allow WiFi TCP/IP stack to be implemented on board. The ESP8266 is capable of either hosting an application or offloading all WiFi networking functions from another application processor.
I wasn't interested in driving the ESP8266 with another controller, but to flash an application and use it as a stand-alone module, mostly to keep any future BOM as low as possible. After taking a look at the ESP8266 features it seemed possible to run most applications from within the device:
- It has GPIO, I2C, ADC, SPI, PWM.
- A 80 MHz operation frequency
- 64 Kb of instruction RAM
- 96 Kb of data RAM
- 64 Kb boot ROM
- Winbond W25Q40BVNIG SPI flash
- RISC architecture
- The core is a 106micro Diamond Standard core (LX3) made by Tensilica.
As we need to consider also the available resources left for the application taking into the account the stack itself, from this page the actual RAM/ROM are about 40 Kb and 64 Kb.
The ESP8266 evaluation board by OLIMEX features a 220VAC/10A relay module and conveniently exposes most pins in a standard 2.54 mm header, which is great to have available when developing. It also features an user button which can also be used to put the ESP2866 in bootloader mode, to allow flashing over UART.
Installing the toolchain
sudo add-apt-repository ppa:dns/gnu -y sudo apt-get update -q sudo apt-get install --only-upgrade autoconf
As a general recommendation install the ESP8266 toolchain as suggested in the /opt/Espressif, as many applications (like the OLIMEX examples and resources) are heavily hard-coded to use this path.
I also recommend to use the suggested Espressif SDK v0.9.3 instead of the newer v.1.2.0, as I (painfully) found that many applications and examples were written for the earlier version, and porting for the new SDK version required more time than I had available for a simple test run.
Flashing the ESP2866
The ESP2866-EVB comes with factory-enabled flash mode, which allows to program the device over UART. I used a cheap USB to serial converter, wired as shown below.
![]() |
| Image taken from Instructables site |
- GND (blue wire to pin 2)
- USB to Serial UART RX pin to ESP2866 UART TX (green wire to pin 3)
- USB to Serial UART TX pin to ESP2866 UART RX (red wire to pin 4)
The ESP8266-EVB datasheet has more information.
To put the device in bootloader mode just make sure the board is powered off, press and hold the user button (the big white one), and while pressing the button power the board (connect to 5VDC).
Making a WiFi enabled power cord switch
I wanted to see how fast would it be to make a connected application. In nearly 10 minutes I had a WiFi enabled power cord switch. The motivation was simple: power on and off anything in my house running at 220V/10A from anywhere in the world (as in my bed), without having to cut or adapt any home appliance for this purpose, a non-intrusive approach to keep my wife happy and myself out of the couch.
The specification was simple enough: power the ESP8266 directly from mains and use the relay with the normally open (NO) mode as devices would normally have to be off. As time was my premise, I
I kept the USB charger casing to isolate the electronics and avoid someone touching mains by accident.
Now for the firmware I used the stock IoT Firmware image from OLIMEX resources, this handy application allows any web developer to easily control most of the ESP8266 evaluation board features, like managing the wireless network, create and poll events and status related to the user button and relay, manage I2C devices, update the Firmware image remotely, amongst others.
| OLIMEX IoT Firmware and sample application |
And that's it! a simple WiFi-enabled power cord in 10 minutes.
I tested with a desk lamp and other appliances (under 10A), as it only requires to plug into the female connector of the power cord is easy to use anywhere.
A future enhancement would be to add sensors like an ambient light or temperature sensor, to provide more information about the current location, maybe a presence sensor to allow an event-based operation. Of course making a proper PCB with a 220VAC/5VDC transformer would be mandatory.
Now to further play with the ESP8266 and dig into the source code.
Thursday, 4 December 2014
Wireless Garden sensing Prototype A and B (Intel Galileo, Spark Core and Grove)
We have a small garden at home and adding sensors to it was merely a matter of time, specially now that winter is coming, and it is time to plant our pepper and tomatoes plants. Below are the two iterations made to my wireless gardening sensor (still in beta stage).
For the first prototype I used the Intel Galileo Board I won at Senzations, the objective was to test the sensors, familiarize with the obtained values, and test publishing to Ubidots. For the test I used my wife's pepper plant.
Light, Temperature and Humidity are variables easy to understand and correlate, but as there was litle information about the Soil Moisture sensor itself, I measured both with the sensor in the free air and submerged into a glass of water, I found out the range was between 0-700 units. The next step was to water the pepper pot and see the Soil Moisture value when the plant if fully watered, then see the chart going down until the next watering session (when the leaves are "sad" as my wife says), so we can see at which values do we have to trigger an alert.
The actual code was mostly taken from Ubidots examples, as the sensors at this present stage are mostlly analogue, it was only required to use the analogRead() call from the Arduino API. The sensors are from Grove: the temperature and humidity sensor is I2C-based, the soil moisture and light sensor are analogue.
With the sensors and the Ubidots platform figured out, the next step was to make the whole thing to run on battery as a stand-alone device. For this I used the Spark Core I won at IoTogether Hackaton along with a battery charger board Isteal borrowed from work, and a 3.7V 800mAh Li-ion battery connected to a battery charging circuit.
To avoid having to solder a wire to the USB 5VDC pin I added a scrambled jumper logic to enable charging the battery when connected to the micro-USB, else the Spark Core will be powered by the battery only. I have also one power input to throw in a solar panel and charge the battery in the day and discharge over the night, but I still have to figure out how to adapt it to the enclosure.
I added 2 Phidget-like connector to be able to connect Phidget sensors or analog ones following the same pin-out (VDC/GND/Signal), and one Ziglet-like connector to connect any I2C-based sensor, as at the end I want to use digital sensors to keep the power consumption as low as possible, having wired a GPIO pin also to the connector to use interrupts from the sensors as well.
The male pin-header exposes unused GPIOs to be used later, for example one wandering idea is to add an MP3 board with an amplifier and a small speaker, as allegedly this helps plants grow, or maybe do a playback of my wife talking to the plants, which one was it? nevertheless it would also be kinda cool to play nature music when presence is detected... this will be likely an improvement to make if the power consumption can be kept low.
One caveat: I was one of the unlucky Spark owners who had a board with faulty DNS resolve, so I had to include an external DNS client to resolve Ubidots IP address, and then add the host property to my header and initiliaze the Server IP address as shown below:
The AWAKE_BEFORE_SLEEP delay makes sure the Spark Core stays awake for 20 seconds, which gives me enough time to reprogram the Spark over the Web IDE from my PC without having to connect the Spark to the host over USB. One of the things on my to-do list is to measure the current consumption of the device.
The whole thing fits into a standard enclosure, one of the things I have still pending to do is to adapt the sensors to the enclosure, make a small window to be able to visualize the LED, and also fix the solar panel. I have convinced my daughters to paint the enclosure with a festive theme, so surely I will post this anytime soon.
So that's it, I'm hoping in the holidays to have time to improve the Prototype B, make some measurements and work on the solar panel. One of the things I will surely test is the ESP8266 cheap WiFI board, but with my Photon already ordered in pre-sale for next year, I think it will make worth the wait, in time for the Prototype C, maybe even a release.
Prototype A: Intel Galileo on board
For the first prototype I used the Intel Galileo Board I won at Senzations, the objective was to test the sensors, familiarize with the obtained values, and test publishing to Ubidots. For the test I used my wife's pepper plant.
Light, Temperature and Humidity are variables easy to understand and correlate, but as there was litle information about the Soil Moisture sensor itself, I measured both with the sensor in the free air and submerged into a glass of water, I found out the range was between 0-700 units. The next step was to water the pepper pot and see the Soil Moisture value when the plant if fully watered, then see the chart going down until the next watering session (when the leaves are "sad" as my wife says), so we can see at which values do we have to trigger an alert.
The actual code was mostly taken from Ubidots examples, as the sensors at this present stage are mostlly analogue, it was only required to use the analogRead() call from the Arduino API. The sensors are from Grove: the temperature and humidity sensor is I2C-based, the soil moisture and light sensor are analogue.
Prototype B: Spark Core
With the sensors and the Ubidots platform figured out, the next step was to make the whole thing to run on battery as a stand-alone device. For this I used the Spark Core I won at IoTogether Hackaton along with a battery charger board I
To avoid having to solder a wire to the USB 5VDC pin I added a scrambled jumper logic to enable charging the battery when connected to the micro-USB, else the Spark Core will be powered by the battery only. I have also one power input to throw in a solar panel and charge the battery in the day and discharge over the night, but I still have to figure out how to adapt it to the enclosure.
I added 2 Phidget-like connector to be able to connect Phidget sensors or analog ones following the same pin-out (VDC/GND/Signal), and one Ziglet-like connector to connect any I2C-based sensor, as at the end I want to use digital sensors to keep the power consumption as low as possible, having wired a GPIO pin also to the connector to use interrupts from the sensors as well.
The male pin-header exposes unused GPIOs to be used later, for example one wandering idea is to add an MP3 board with an amplifier and a small speaker, as allegedly this helps plants grow, or maybe do a playback of my wife talking to the plants, which one was it? nevertheless it would also be kinda cool to play nature music when presence is detected... this will be likely an improvement to make if the power consumption can be kept low.
One caveat: I was one of the unlucky Spark owners who had a board with faulty DNS resolve, so I had to include an external DNS client to resolve Ubidots IP address, and then add the host property to my header and initiliaze the Server IP address as shown below:
http_header_t headers[] = {
{ "Content-Type", "application/json" },
{ "X-Auth-Token" , TOKEN },
{ "host", "things.ubidots.com" },
{ NULL, NULL }
};
IPAddress dnsServerIP(8,8,8,8);
IPAddress remote_addr;
DNSClient dns;
char serverName[] = "things.ubidots.com";
void setup() {
request.port = 80;
dns.begin(dnsServerIP);
dns.getHostByName(serverName, remote_addr);
request.ip = remote_addr;
}
Then to take advantage of the Spark low power mode and try to save battery as most as possible, I use the SLEEP_DEEP_MODE to put the Spark to sleep and awake after 5 minutes, rebooting the code with no memory retention, which is fine in my case as I only want to take single readings and upstream these. The code runs as follows:void loop() {
// Read data from the sensors
getData();
// Send data to Ubidots
postData();
// Short blink to indicate we have finished posted
blink_led(500);
// Stay awake enough time to allow being reprogramed
delay(AWAKE_BEFORE_SLEEP);
// Put the core back to sleep
Spark.sleep(SLEEP_MODE_DEEP, SLEEP_SECONDS);
}
The AWAKE_BEFORE_SLEEP delay makes sure the Spark Core stays awake for 20 seconds, which gives me enough time to reprogram the Spark over the Web IDE from my PC without having to connect the Spark to the host over USB. One of the things on my to-do list is to measure the current consumption of the device.
The whole thing fits into a standard enclosure, one of the things I have still pending to do is to adapt the sensors to the enclosure, make a small window to be able to visualize the LED, and also fix the solar panel. I have convinced my daughters to paint the enclosure with a festive theme, so surely I will post this anytime soon.
So that's it, I'm hoping in the holidays to have time to improve the Prototype B, make some measurements and work on the solar panel. One of the things I will surely test is the ESP8266 cheap WiFI board, but with my Photon already ordered in pre-sale for next year, I think it will make worth the wait, in time for the Prototype C, maybe even a release.
Bring Oneiric-based distros back to live in Linaro and IGEP board
Following the end-of-year tradition of updating production boards, I found an ISEE IGEP v2 board running Linaro distribution on an Oneiric-based release, which reached end of life on May 2013. One option would be upgrading to a new LTS distro, but as time was limited and the current owner has a if-works-don't-touch strict policy, I choosed instead to update at least its sources:
Just edit the /etc/apt/sources.list file and replace with the following:
Then run:
Don't forget to also test for ShellShock vulnerability.
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/oneiric-security/main/source/Sources 404 Not Found
Just edit the /etc/apt/sources.list file and replace with the following:
deb http://old-releases.ubuntu.com/ubuntu/ oneiric main deb-src http://old-releases.ubuntu.com/ubuntu/ oneiric main deb http://old-releases.ubuntu.com/ubuntu/ oneiric-updates main deb-src http://old-releases.ubuntu.com/ubuntu/ oneiric-updates main deb http://old-releases.ubuntu.com/ubuntu/ oneiric universe deb-src http://old-releases.ubuntu.com/ubuntu/ oneiric universe deb http://old-releases.ubuntu.com/ubuntu/ oneiric-updates universe deb-src http://old-releases.ubuntu.com/ubuntu/ oneiric-updates universe deb http://old-releases.ubuntu.com/ubuntu oneiric-security main deb-src http://old-releases.ubuntu.com/ubuntu oneiric-security main deb http://old-releases.ubuntu.com/ubuntu oneiric-security universe deb-src http://old-releases.ubuntu.com/ubuntu oneiric-security universe
Then run:
sudo apt-get update
Don't forget to also test for ShellShock vulnerability.
Wednesday, 3 December 2014
Fix Shellshock on non LTS/deprecated Unix distros
Plenty of things have been said about Shellshock vulnerability and solutions, most of them consisting of upgrading the bash module for LTS distros, but lately as I have dusted my ALIX board based on Voyage 0.9.0 distribution, I found this was not an option: even after upgrading and downloading the bash packet from the dist pool, there were requirements missing to upgrade/install bash from the packet manager. This was my current bash version:
The bash version did not matched the fixed ones, anyways to test if you are affected you can run on a terminal the code below, if both lines are showed, then it is affected.
After running the script the bash has been patched and the shellshock test now ommits the "busted" line.
Sources:
# bash --version GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu) Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
The bash version did not matched the fixed ones, anyways to test if you are affected you can run on a terminal the code below, if both lines are showed, then it is affected.
# env X="() { :;} ; echo busted" `which bash` -c "echo completed"
busted
completed
I found a fix at ShellShocker and it was as easy as running the snippet below (although I would not recommend executing remote scripts, it is not a good practice), but if you are curious about what it does, or you want to run this yourself, the sources are also listed below.curl https://shellshocker.net/fixbash | sh
After running the script the bash has been patched and the shellshock test now ommits the "busted" line.
# bash --version GNU bash, version 4.3.30(1)-release (i586-pc-linux-gnu) Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
Sources:
Subscribe to:
Posts (Atom)






