Archive

Posts Tagged ‘open source’

How to Build and Flash ESPurna Open Source Firmware to Sonoff POW Wireless Switch

December 3rd, 2016 15 comments

ITEAD Studio Sonoff family is comprised of various inexpensive ESP8266 WiFi power switch, and the company sent me two of their latest CE certified models with Sonoff TH16 + external temperature & humidity probe, and Sonoff POW to measure power consumption. I checked the hardware is the first part of the review, and used Sonoff TH16 to control a water pump with the stock firmware and Ewelink Android app in the second part. It works reasonably well, but it relies on the cloud, so if you lose your Internet connection or the service closed, you can’t control the relay manually anymore. Luckily, the UART pins are exposed on Sonoff switches so you can solder a 4-pin header and connect a USB to TTL to flash your own firmware.

Click to Enlarge

Click to Enlarge

Please don’t connect Sonoff devices to the mains when programming them, it’s very dangerous, instead the USB to TTL board will power the system, and will allow you to program the board safely. Later you’ll be able to update the firmware, if needed, over the network.

The next step is to select the firmware you want to use, and I’ve been advised two firmware for ESP8266, namely ESPurna specifically designed for Sonoff devices, and ESPEasy with a larger community of users. The latter may be usable to control the relay, but it has yet to support HLW8012 chip used to measure power consumption in Sonoff POW, so I decided to go with ESPurna.

That’s the description of the firmware from its bitbucket page:

ESPurna (“spark” in Catalan) is a custom C firmware for ESP8266 based smart switches. It was originally developed with the ITead Sonoff in mind. Features:

  • Asynchronous WebServer for configuration and simple relay toggle with basic authentication
  • Communication between webserver and webclient via websockets with secure ticket check
  • Flashing firmware Over-The-Air (OTA)
  • Up to 3 configurable WIFI networks, connects to the strongest signal
  • MQTT support with configurable host and topic
  • Manual switch ON/OFF with button (single click the button)
  • AP mode backup (double click the button)
  • Manual reeset the board (long click the button)
  • Visual status of the connection via the LED
  • Alexa integration (Amazon Echo or Dot) by emulating a Belkin WeMo switch
  • Support for automatic over-the-air updates through the NoFUSS Library
  • Support for DHT22 sensors
  • Support for the HLW8012 power sensor present in the Sonoff POW
  • Support for current monitoring through the EmonLiteESP Library using a non-intrusive current sensor (requires some hacking)
  • Command line configuration

I could not find firmware release for ESPurna, but Xose Pérez – the developer – has provided some basic instructions to build and flash the firmware to Sonoff. Those are not really detailed however, and it took me nearly a full day to successfully build and flash the firmware to Sonoff POW, mostly because I was not quite familiar with most of the tools used. So I’ve reproduced the step I went through in Ubuntu 16.04, and hopefully this can help people getting things done more quickly.

Let’s retrieve the source code, and enter the code directory first:

You can build the project with PlatformIO or the Arduino IDE. The instructions are for PlatformIO so that’s what I used. There are two ways to build the code with the project wither using Platform IDE for Atom and the command line, or simply using the command line. With insights, I ended up using the command line, but I’ll show both methods.

Setup PlatformIO IDE for Atom to build ESPurna

First, you’ll need to download PlatformIO IDE for Atom for your operating systems, and install it. For Ubuntu 16.04, I selected “Download .deb” for Linux and installed it through through Ubuntu Software program. Alternatively, after download, you can install it from the command line:

You can now start Atom program in Ubuntu dash, select Open Project, and browse for espurna/code directory to load the project we’ve just gotten from Bitbucket.

Click to Enlarge

Click to Enlarge

The tick button on the top left corner is to build the project, and the right button just under is to upload the firmware to the target board. But if we try to build the firmware now it will fail with an error about “espressif8266_stage”. That’s because we need to install Espressif 8266 (Stage) development platform. First we need to enable Developer mode in the IDE by going to the top menu to select PlatformIO->Settings->PlatformIO IDE, and checking “Use development version of PlatformIO“.

platformio_core_enable_development_version

Click to Enlarge

Now install PlatformIO shell commands from either a system Terminal, or PlatformIO IDE terminal (PlatformIO->Terminal->New Terminal):

and finally install ESP8266 development platform:

At this point you can click on the tick icon to build the default “node-debug” environment, a build output window will show in the IDE, and quickly disappear if the build is successful.

Setup PlatformIO via Command Line to Build ESPurna

If instead we want to use the command line we can install the latest pip version, the developer version of PlatformIO, and the staging version of ESP8266 development platform:

You can check the build environment is set properly by running the following command in espurna/code directory:

It will automatically download, build and install all dependencies and build for “node-debug” firmware for NodeMCU board. If it is successful, it will end as follows:

So I find the command line option much more easy and straightforward.

Build ESPurna for Sonoff POW

However, we are not using NodeMCU board here, but Sonoff POW, and there are two environments defined just for that:

  • sonoff-pow-debug – Build firmware to flash over serial
  • sonoff-pow-debug-ota – Build OTA firmware to upgrade the firmware over the network

The parameters for each environment are all defined in platformio.ini. First we need to build sonoff-pow-debug environment:

But it failed with an error message related to hlw8012 library:

I reported the issue on Bitbucket, but the main developer could not reproduce the issue. Eventually I found out that it could be a PlatformIO bug, as the system does not recursively checking for includes outside of main.ino. So I added <hlw8012.h> in the main.ino as follows:

and the build could complete:

Since we’ve already changed the code, you may also consider changing “#define ADMIN_PASS  fibonacci” in code/src/config/general.h to use a different default password. The password can also be changed in the web interface, but this makes sure you won’t have a device somewhere with the default password common to most users.

Flashing Firmware to Sonoff POW

Now that we’ve made sure the firmware could build, it’s time to flash it to the device.

First we need to setup some udev rules to allow flashing over serial:

Now connect the USB to TTL to a USB port on your computer, press the button (connected to GPIO0) on Sonoff POW for several seconds until both LEDs are off to make sure you are in bootloader mode, and start flashing with:

Success! Great. If you have your own firmware to flash it may be useful to know the actual command used to flash the firmware was:

Building and Flashing the ESPurna filesystem

Wait! We’ve just flashed the firmware, isn’t it all? Nope, as the webserver files are stored in another partitions, and compressed in a single index.html.gz file for better performance. The exact reasons why are further explained here.

We’ll need Node.js and gulp command line client:

Now inside espurna/code folder , we can check if building the file systems works with two commands:

Here my successful gulp attempt:

Finally, we can run the following (which also runs the two commands above) to flash the file system to the board, after entering bootloader mode by pressing the button:

Now that’s done.

A Quick look at ESPurna Web Interface

ESPurna firmware and filesystem has now been flashed to Sonoff POW. But does it work?

Click to Enlarge

Click to Enlarge

I can see a new SONOFF_POW_XXXXX access point, so that does look good. I can connect using the default password “fibonacci”, then go to my web browser to access http://192.168.4.1, and login again with admin/fibonacci credentials.

Click to Enlarge

Click to Enlarge

ESPURNA 1.03 interface goes to the status menu first, and there I can turn on and off the relay remotely, and check the power consumption in watts, which remains at 0 watt since I have not connected it to the mains yet. It’s also possible to turn the relay on and off with the button, and there an option to select whether to turn on or off the relay at boot time, which is great since I need it on at all times.

The web interface also allows you to change general parameters including the hostname and password, as well as enable or disable the HTTP API (disabled by default). The WiFi section is used to connect to up to 3 wireless routers, the MQTT section lets you configure an MQTT (Mosquito) broker, and the power section is used to calibrate the power monitoring device.

If you just intend to check the current power consumption and turn on and off the switch with your phone, you don’t have to do anything else. But I’d like to find some ways to draw daily, weekly, monthly charts of my office power consumption using either MQTT or the HTTP API. I’ll have to study how to do that, and that will hopefully be the topic of my next post about Sonoff POW.

Sonoff POW can be purchased on ITEAD Studio for $10.50 plus shipping, but is currently out of stock with the company manufacturing a third batch soon.

Hack Autonomous Driving into Your Car with Open Source Hardware Comma Neo and Open Pilot Software

December 1st, 2016 4 comments

George Hotz setup Comma.ai company and worked on a commercial project called Comma One to add autonomous driving to some car models, but then the US highway authorities started to ask questions and promised ever increasing fines if he could not comply with some specific safety regulations/requirements, and eventually he decided to cancel the project due to the regulatory burden. A few weeks passed since the cancellation, and he has now released Open Pilot auto-pilot software and Comma NEO a work-in-progress open source hardware platform connecting to Qualcomm Snapdragon 820 powered OnePlus 3 smartphone to run the software.

Comma NEO

Comma NEO

The system is said to implement “Adaptive Cruise Control (ACC) and Lane Keeping Assist System (LKAS) for Hondas and Acuras”, and performs about the same as “Tesla Autopilot at launch, and better than all other manufacturers”.

Open Pilot currently only supports the Acura ILX 2016 with AcuraWatch Plus and the Honda Civic 2016 Touring Edition, but since the software is open source, it should be possible to adapt it to other Honda and Acura models with some tinkering, and other car manufacturers could also be added to the list but would require much more work. The system leverages the cars’ cruise control system which becomes disabled at lower speed, so self-driving only works at higher speeds, 18+ mph or 25+ mph depending on the car’s model.

The video above should be using Open Pilot software, but I’m unclear which exact hardware it is using (Comma One or Comma NEO).

The software also has the following disclaimer “THIS IS ALPHA QUALITY SOFTWARE FOR RESEARCH PURPOSES ONLY. THIS IS NOT A PRODUCT. YOU ARE RESPONSIBLE FOR COMPLYING WITH LOCAL LAWS AND REGULATIONS. NO WARRANTY EXPRESSED OR IMPLIED”. But if it does not bother you, George has put together a step by step guide showing exactly how to buy all parts (~$700) from 6 different shops, solder the components to NEO Rev A board, wire and test the board, and assemble the case.

Via Arstechnica and Nanik.

$59 HiFive1 Arduino Compatible Board is Powered by Sifive Open Source RISC-V MCU (Crowdfunding)

November 30th, 2016 8 comments

Royalty-free RISC-V instruction sets has been getting in the news in the last few years with various MMU designs from companies or projects like lowRISC, PULPino, and SiFive, and recently there are been rumors that Samsung may use RISC-V in their future IoT SoCs. Many projects are still in progress, and while you can get involved in OnChip Open-V MCU crowdfunding campaign to their get the MCU or a development board, the cost for the MCU ($49) and development board ($99) is a little on the high side, and delivery is expected in 2018 for most rewards. SiFive appears to have a more interesting open source RISC-V solution with HiFive1 Arduino compatible board going for $59 and slated to ship between December 2016 and February 2017.

HiFive1 Board

HiFive1 Board

HiFive1 development board specifications:

  • MCU – SiFive Freedom E310 (FE310) 32-bit RV32IMAC processor @ up to 320+ MHz (1.61 DMIPS/MHz)
  • Storage – 128 Mbit SPI flash
  • I/Os
    • 19x Digital I/O Pins
    • 19x external interrupt pins
    • 1x external wakeup pin
    • 9x PWM pins
    • 1/3 SPI Controllers/HW CS Pins
    • I/O Voltages –  3.3V or 5V supported
  • USB – 1x micro USB port for power, programming and debugging
  • Power Supply – 5 V via USB or 7 to 12V via DC Jack; Operating Voltage: 3.3 V and 1.8 V
  • Dimensions – 68 mm x 51 mm
  • Weight – 22 g

sifive-fe310

The company’s Freedom SDK with the RTL files for Freedom E310 (and U500) MCUs will allow you to actually play and/or modify the MCU on an FPGA platform, which can be useful for education or if you want to create your own MCU based on SiFive design. If you don’t have the know-how the company’s “chips-as-a-service” offering can customize FE310/U500 MCU to meet your needs.

 Most users will probably just program the board with the Arduino IDE, and many of the usual development tools have already been ported to RISC-V architecture. The processor is also quite faster than our typical Arduino, being about 10 times faster than Intel Curie and Atmel SAMD21G18 used in respectively Arduino 101 and Arduino Zero.

hifive1-vs-arduino

Power efficiency (@ 200 MHz) appears to be much higher compared to Atmel AVR and Intel Quark. However, based on ARM Cortex M0 product brief (I could not find data for M0+), 10DMIPS/mW can be achieved using 180ULL process, and 75 DMIPS/mW with 65LP process.

If you are interested, you can get the board on Crowdsupply with the HiFive1 devkit going for $59 and shipping in February 2017, but if you want to have a piece of history, you may consider HiFive1 Founder Edition for $79 with SiFive Founding Team’s Signature on the silkscreen and shipping at the end of December 2016. Shipping is free to the US, and $15 to the rest of the world.

RISC-V could be a serious competitor to ARM and MIPS in the MCU/IoT space in the years ahead, as it’s royalty-free, and the RISC-V foundation has many players including some heavy weights such as Google, AMD, Microsemi, Qualcomm, Nvidia and more…

Thanks to noone for the tip.

$49 Dashbot Car Dashboard Assistant is Powered by C.H.I.P Pro Allwinner GR8 Module (Crowdfunding)

November 18th, 2016 2 comments

Most companies specializing in development boards may sell a few accessories for their boards, but usually leave product design to their customers. Next Thing Co. does that too, but the company also produces some products like PocketCHIP portable Linux computer & retro game console, and more recently Dashbot, a voice controller assistant for your car’s dashboard powered by CHIP Pro module.

dashbot

Dashbot hardware specifications:

  • CPU Module – CHIP Pro with Allwinner GR8 ARM Cortex A8 processor @ 1.0 GHz, 512MB NAND flash, 256 DDR3 RAM, 802.11 b/g/n WiFi, Bluetooth 4.2
  • External Storage – micro SD slot
  • Display – Red LED display
  • Audio – 32-bit audio DSP for beamforming & noise suppression; fairfield audio pre-processor with 24-bit ADC; high fidelity MEMS microphone array (106 dB dynamic range)
  • USB – 1x USB host port
  • Power Supply – 5V via USB port or 12V via power port (aka cigarette lighter) + backup LiFePo4 battery
  • Dimensions – 84 x 60 x 28 mm

The bot runs mainline Linux, source code will be available, as well as hardware design files making open source hardware (likely minus CHIP Pro module itself). Once you’ve stuck the magnetic adhesive mount to the dashboard, and placed Dashbot on top, you can connect it to your car stereo via Bluetooth or your car’s auxiliary jack. Wait what?  My car does not have any of those two connection methods… But no problem as the company also offers a Retro Pack adding an FM transmitter and cassette adapter for older cars.

dashbot-connection-guideThe main goal of Dashbot is to keep your smartphone in your pocket, and control it with your voice in order to keep your eyes on the road. But you’ll still need your phone, and after installing Dashbot app on your Android 5.0+ or iOS 10+ smartphones, you’ll be able to tell Dashbot to start playing music from online services like Spotify, Soundcloud, Google Play Music, and others, or tell it to “go home” and it will show the directions from Google Maps on the red LED display, and of course you can also answer phone calls, and reply to SMS.

Dashbot “AI powered hands-free car kit” launched on Kickstarter a few hours ago, has already raised over $50,000, and I’m confident it will surpass its $100,000 funding target. A $49 pledge should get you Dashbot, a power port for your cigarette lighter and an AUX cable, but if you have a car with a stereo that does not come with Bluetooth nor an AUX IN jack, you can get the Retro Pack for $65 with an FM radio/cassette player adapter. They also have rewards with an OBD-II dongle, and bundles with multiple Dashbots. Shipping adds $9 or more depending on rewards and destination, and delivery is planned for July 2017.

GR-LoRa is a Reverse-Engineered Open Source Implementation of LoRa PHY

November 15th, 2016 8 comments

LPWAN standards such as LoRa or Sigfox allow you to transmit data over long distance, at ultra low power (up to 10 years on a AA battery), and for free if your use your own network (P2P or gateway), or a few dollars per years if you go through a network provider. The low cost is possible since those standards rely on 900 MHz ISM bands, meaning nobody has to pay millions of dollars to the government to obtain a license fee. Matt Knight looked at LoRa, and while Level 2 and 3 of the protocol (LoRaWan) has public documentation, Level 1 (LoRa PHY) is proprietary and the standard is proprietary.

microchip-rm2903-ettus-b210-sdrSo he decided to reverse-engineer LoRa PHY using Microchip RN2903 based LoRa Technology Mote and Ettus B210 USB software defined radio, and software packages and tools such as Python and GNU Radio to successfully deliver GR-LoRa open source “GNU Radio OOT module implementing the LoRa PHY”.  He presented his work at GNU Radio Conference 2016 on September 15, and the video is worth a watch. He first explains why LPWAN IoT standards are awesome, the motivation about reverse-engineering work (mostly security), the hurdle (e.g. lies in documentation), the results, and work to be done.

You’ll find the presentation and the research paper on Github.

Thanks to Emanuele for the tip.

RabbitMax Flex IoT & Home Automation Board and Kit for Raspberry Pi

October 7th, 2016 4 comments

RabbitMax Flex is an add-on board for the Raspberry Pi boards with 40-pin headers, namely Raspberry Pi Model A+ and B+, Raspberry Pi 2, Raspberry Pi 3 and Raspberry Pi 0, destined to be used for Internet of Things (IoT) and home automation applications thanks to 5x I2C headers, a relay, an LCD interface and more.

I’ve received a small kit with RabbitMax Flex boards, a BMP180 temperature & barometric pressure I2C sensor, and a 16×2 LCD display.

Click to Enlarge

Click to Enlarge

1602a-lcd-display
bmp180-i2c-sensor

RabbitMax Flex specifications:

  • Relay – Songle SRD-05VDC-SL-C supporting 125V/250VAC up to 10A, 30VDC up to 10A
  • Storage – EEPROM with some system information for identification
  • IR – IR LED, IR receiver
  • Misc – Buzzer, Button, RGB LED
  • Expansion
    • Header for LCD character display + potentiometer for backlight adjustment
    • 5x 4-pin headers for I2C sensors
  • Dimensions – Raspberry Pi HAT compliant
Click to Enlarge

Click to Enlarge

The assembly of the kit is child’s play as you don’t even need tools. First insert the HAT board on top of your Raspberry Pi board, add the LCD display, and whatever I2C sensors you please.

Click to Enlarge

Click to Enlarge

I’ve done so on my Raspberry Pi 2 board and battery kit. I have not tried the software part yet, but the platform has been tested on Raspbian, with a custom Linux OS built with the Yocto Project coming soon. Currently three sensors are supported including a temperature and barometric pressure sensor (BPM180), a temperature and humidity sensor (HTU21) and a light sensor (BH1750), but you could also connect any other I2C sensors provided you work on the code to enable support.

You’ll find documentation, software, example projects, tools, and soon KiCAD files on RabbitMax github’s account, and some extra info on RabbitMax.com website. RabbitMax Flex board is now sold for $49.90 on Tindie.com, but if you are patient enough, you should be able to buy it for a significantly lower price via an upcoming crowdfunding campaign.

BeagleBone Black Wireless Board Gets WiFi and Bluetooth 4.1 LE, Drops Ethernet

September 27th, 2016 No comments

The BeagleBone Black is still one of the most popular development boards around, but in a world going more and more wireless, it only comes with a wired Ethernet interface. Seeed Studio BeagleBone Green Wireless and Neuromeka BeagleBone Air already provided BeagleBone compatible boards with WiFi and Bluetooth LE, as well as Zigbee for the latter, but now BeagleBoard.org themselves have launched BeagleBone Black Wireless with WiFi and Bluetooth 4.1 LE based on Octavo Systems OSD3358 System-in-Package with Texas Instrument Sitara AM3358 processor, 512 MB RAM, TI LDO and PMIC, and many passive components.

Click to Enlarge

Click to Enlarge

BeagleBone Black Wireless specifications:

  • SoC – Texas Instruments Sitara AM3358 Cortex A8 @ 1 GHz with PowerVR SGX530 GPU
  • System Memory – 512 MB DDR3L
  • Storage – 4GB eMMC flash + micro SD slot
  • USB – 1x mini USB client port for power & communication, 1x USB host port
  • Connectivity – 802.11 b/g/n WiFi + Bluetooth 4.1 LE with 2x u.FL antenna connectors
  • Video & Audio Output – micro HDMI up to 1280×1024 resolution.
  • Expansion Connectors – 2x 46-pin headers
  • Misc – LEDs for WiFi, Bluetooth, Power, and 4x user LEDs; Reset, boot, and power buttons
  • Debugging – JTAG header, serial console
  • Power – mini USB, DC Jack, or 5VDC via expansion header
  • Dimensions – 86.4 x 53.4 mm

The board is preloaded with Debian with Cloud9 IDE on Node.js with BoneScript.js library, and also support other Android and Linux based operating systems support by other BeagleBone boards. Cadsoft Eagle schematics and PCB layout have already been released on github. BeagleBone Black Wireless drops the Ethernet port just like BeagleBone Green Wireless, but keeps the micro HDMI port, which on Seeed Studio’s port is replaced by 4x USB ports and Grove connectors.

You’ll find some more details on BeagleBoard.org Black Wireless page, and can purchase the board on Mouser (Part #: BBBWL-SC-562) for $68.75.

MinnowBoard Turbot SBC Gets a Quad Core Atom E3845 Processor, Better Ethernet, and a Fansink

September 6th, 2016 10 comments

MinnowBoard Turbot open source hardware SBC was released in 2015 with an Intel Atom E3826 dual core Bay Trail-I processor, 2GB RAM, SATA and Gigabit Ethernet support, and a new version – MinnowBoard Turbot Quad – with a more powerful quad core processor, an heatsink and fan, and better Ethernet connectivity will be launched in December.

Click to Enlarge

Click to Enlarge

MinnowBoard Turbot Quad “MBT-4210” board specifications:

  • SoC – Intel Atom E3845 quad core Bay Trail-I processor @ 1.92 GHz with Intel HD graphics @ 542 / 792 MHz (10W TDP)
  • System Memory – 2GB DDR3L 1067 MT/s (Soldered)
  • Storage – 1x SATA2 3Gbs, 1x micro SD card slot, , 8 MB SPI Flash for firmware (Tianocore UEFI, Coreboot, SeaBIOS)
  • Video & Audio Output – 1x micro HDMI connector
  • Connectivity – 10/100/1000M Ethernet RJ-45 connector (Intel i211 instead of Realtek NIC on first board)
  • USB – 1x USB 3.0 host, 1x USB 2.0 host
  • Debugging – Serial debug via FTDI cable, firmware flash port header
  • Expansion headers
    • Low-speed expansion (LSE) port – 2×13 (26-pin) male 0.1″ pin header with access to SPI, I2C, I2S Audio, 2x UARTs (TTL-level), 8x GPIO (including 2x supporting PWM), +5V, and GND
    • High-speed expansion (HSE) port –  60-pin high-density connector with access to 1x PCIe Gen 2.0 Lane, 1x SATA2, 1x USB 2.0 host, I2C, GPIO, JTAG, +5V, and GND
    • 8x buffered GPIO
  • Power Supply – 5V/4A DC input via 2.5mm center pin positive power jack; 5V DC output via  2-pin header
  • Dimensions – 99 x 74mm
  • Temperature Range –  Operating: TBD; Storage: -20 to +85 deg C
  • Certifications – FCC Class B, CE, IEC-60950, RoHS/WEEE

The company claims the new processor is 2.5 times faster than the dual core processor used in the first board, likely referring to multi-core performance at a higher clock speed, and the fansink should make it more suitable for higher temperature applications. Gigabit Ethernet is also supposed to benefit from replacing a Realtek GbE controller by Intel i211.

Click to Enlarge

MinnowBoard Case – Click to Enlarge

The board leverages MinnowBoard MAX ecosystem, with support for many different operating systems including Debian GNU/Linux, Brillo, Windows 8.1 / 10, Android 4.4, and Ubuntu. MinnowBoard Turbot (Quad) is also compatible with the Yocto Project, 64-bit Intel firmware, Coreboot and U-boot, and more with details available on Minnowboard Wiki. The board will be open source hardware with the files released under a Creative Commons BY-SA 3.0 license. The hardware should not be that different from MinnowBoard Turbot (dual core) whose schematics, PCB layout, gerber files, and BoM can be found on MinnowBoard Turbot Wiki.

The board can be pre-ordered for $189.95 on Netgate, but you may consider adding accessories like a metal case (+$19), 5V/2A or 4A power supply ($10.95/$12.95), and/or a HDMI cable ($9.995). Bear in mind that shipping is only scheduled for December 2016.

Thanks to Freire for the tip.