Archive

Posts Tagged ‘itead studio’

Mini Review of Nextion Enhanced NX8048K070 7″ Display with Enclosure for HMI Applications

June 21st, 2017 2 comments

I reviewed some Nextion touchscreen a while ago. Those were 2.4″ and 5″ serial TFT displays with optional resistive touch support that could be used in standalone mode, or connected to an MCU board over UART to control external hardware. The user interface could be designed and emulated in Windows based Nextion Editor program before uploading it to the display via UART or micro SD card. ITEAD Studio has recently launched Nextion Enhanced NX8048K070 family of 7″ displays with resistive or capacitive touch panels, and support for GPIOs. The company sent me the capacitive model with enclosure for evaluation, so I’ll have a quick look at the hardware and Nextion Editor in this mini review.

Nextion Enhanced NX8048K070_011C Unboxing

I received it in a package from “ITEAD intelligent solutions” with basic description with

  • Model: NX8048L070_011C with enclosure
  • Outside dimensions : 275 x 170 x 50 mm (That’s the package dimensions)
  • Product size: 218 x 150 x 22.5 mm
  • Gross weight: 0.598kg

Click to Enlarge

The display comes with a UART cable, or small micro USB power board, and a wall mounting kit.

Click to Enlarge

If we check the other side of the display, we’ll find the UART connector on the left, a micro USB slot on the bottom right, and the GPIO connector that inconveniently requires a flat cable, so you’d have to make your own board to connect external hardware, or purchase the company’s $5 expansion board, which is not included in the kit by default. There’s also the almost-compulsory typo found on many devices made in China: “Human Mechine Interface”.

Click to Enlarge

The thickness is indeed 22 mm, but if you fully embed the display into a wall, the visible thickness will be 6 mm.

You may have to open the bottom cover, as you’ll need to add a battery in case you want to use the RTC function.

Click to Enlarge

Let’s have a look an the main IC while we have the case open:

I close the case back, and power the display via the micro USB power supply board, and a USB power adapter.

Click to Enlarge

It’s a simple demo with a background image, some text, a slider, and 4 different pages, which I’ll demonstrate below after doing some simple modifications.

Nextion Editor and NX8048K070 Demo Sample

Nextion Editor is a Windows program, but a while ago, I was told it also worked with Wine in Ubuntu. So I downloaded the latest version (v0.47), and while the installation started, it eventually failed in Ubuntu 16.04. So I reverted to using Windows 7 in VirtualBox. I also downloaded and extracted Enhanced_Nextion_5.0-7.0_Demo.zip found at the bottom of Wiki page, which I then opened from Nextion Editor.

Click to Enlarge

The user interface will allow you to add various items from the Toolbox including text, scrolling text, numbers, buttons, pictures, progress bars, gauges, check boxes, and so on. As with the previous version, you’ll also need to import and convert font with a fixed size. The demo already has four of those defined. You can also add and link several pages with 4 pages used in the demo, and the Attributes section is used to defined parameters for the selected item

Click to Enlarge

I just added text. It should have been easy, but I was very confused at the beginning, since nothing would show up when I clicked on “Text” in toolbox. I could change the attributes, but the text would not be displayed. I went back to check the old review, and I used “Add Component” menu in Nextion v0.30 at the time, but that menu does not exist anymore. Finally, I noticed the 800×480 display was not shown completely, on the text was located on the top left of the UI. I delete the dozen text items I had created, and added “CNXSoft was here!” at the end of the list. The user interface is not really intuitive, so I’d still recommend to read the user guide, even some of the parts are outdated, as it should help getting started, and they have examples with Arduino. To control GPIOs on the display, you’d need to use cfgpio code.  In case, you run into troubles because the documentation is not quite as good as expected, you can always try your luck in the forums.

You can click on Compile to check for errors in your user interface, and then Debug to launch the simulator.

This will allow you to test the UI as if it was running in the display itself. You can even send keyboard or MCU commands. Once you are happy with the results, click on Operation->Upload to Nextion to upload the UI to the display. I had some troubles getting the display work when I connected it through my serial debug board via USB hub (the display would blink), but the problem was solved by connecting it directly to the USB power from my computer. The upload still failed as the demo is configured for the 5.0″ board, and it correctly detected a 7.0″ board. The fix was easy, as I just had to select Device ID, and change NX8048K050_011 to NX8048K070_011.

Click to Enlarge

After that the upload could start with the Nextion display properly detected.

It took 6 minutes and 35 seconds to upload the ~4MB user interface to the display, so it’s not really fast. That mean if you have  ~32MB UI, it would take close to 50 minutes. In that case, it would be much faster load the UI from the micro SD card. In that case, you need to copy the .tft file found via Nextion->File->Open build folder.

Here’s a quick overview and demo.

Nextion Enhanced 7″ display can be purchased for $88 with resistive touch and $108 with capacitive touch.

$23 Sonoff 4CH Pro 4-Channels WiFi & RF Switch Ships in a DIN Rail Enclosure

June 14th, 2017 9 comments

ITEAD Studio’s Sonoff family is a collection of really useful and inexpensive home automation devices which have been featured multiple times on CNX Software with either to stock firmware and eWelink app, or open source firmware developed by the community. I’m using a Sonoff TH16 to control a water pump, a Sonoff Pow to monitor my office’s power consumption, and Karl used some Sonoff switches to control his lights at home. The company has now launched Sonoff 4CH Pro with 4 relays that can be controlled with buttons on the unit, WiFi, or RF remote controls, and comes in a DIN Rail enclosure.

Sonoff 4CH Pro switch specifications:

  • Connectivity – ESP8266 WiFi module and 433 MHz receiver
  • Relays – 4x HUIKE 230V/10A relays (max 2200W per relays) with NC and NO connection
  • Configuration –  K5 & S6 switch for mode selection; K6 switch for time selection (0.5 to 4s)
  • Misc – 4x user button to turn on/off the relays, 4x LED for relay status, 1x WiFi LED; unpopulated header to program ESP8266 module
  • Power Supply – 5 to 24VDC via power barrel or 90 to 250VAC via “push buttons” terminal block

The board comes pre-loaded with a default firmware working with eWelink app for Android and iOS. The company explain there are three modes of operation which can be controlled with K5, K6 and S6 switches for each relay:

  • Self-locking mode – Each relay can be turn on and off independently.
  • Interlock mode – Only one of the relay can be turned on at a given time. For example if R1 is on, and your press R2 to turn it on, R1 will automatically turn off
  • Inching mode – A button press on the unit, mobile app, or RF/WiFi remote control will turn on the relay for X seconds as defined by K6 “delay” switch. This could be useful for locking mechanisms.

You can select modes per relay, for example R1 and R2 set to self-locking mode, and R3 and R4 to interlock mode. The company also explains you can connect two AC or DC motors using two relays per motor with only one motor controllable at a given time.

The device also supports on/off timer, and works with Alexa and Nest. Eventually, there could be open source firmware for Sonoff 4CH Pro with projects like ESPurna or Sonoff-Tasmota, since the company included the header to update the firmware as the did in their previous models.

Sonoff 4CH Pro is not available right now, but is still listed for $22.90 on ITEAD Studio website, and you can register your email to get informed when the product launched. Note that the RF remote is not included, and if you need it you can purchase it for $4.50 plus shipping.

Nextion Enhanced NX8048K070 is a 7″ Resistive or Capacitive Programmable Touch Display with an Optional Enclosure

May 15th, 2017 No comments

Nextion displays are designed to be controlled by MCU boards with the user interface designed in Nextion Editor drag-and-drop tool. ITEAD Studio launched them in 2015, and I played with Nextion 2.4″ and 5.0″ models, but at the time, I found the Windows only Nextion Editor program not to be that user-friendly and inconvenient to use, as for example, UI designs do not automatically scale across all display sizes. The company is now back with a 7″ model, available with resistive or capacitive touch panel, and featuring an ARM7 processor exposing 8 GPIOs.

Nextion Enhanced NX8048K070 (_011) specifications:

  • CPU – ARM7 processor @ 108 MHz with 8K RAM, 1024 EEPROM, 1024 bytes instruction buffer
  • Storage – 32MB flash memory, micro SD card slot
  • Display – 7″ TFT display with resistive or capacitive panel; resolution: 800×480; 65K colors; adjustable brightness: 0 to 230 nit
  • Expansion – 8x GPIOs including 4x PWM, 4-pin serial interface to MCU board
  • Misc – Built-in RTC + battery slot
  • Power Supply – 5V/2A through micro USB to 2-pin power board
  • Dimensions – Display + board only: 181 x 108 mm; enclosure: 218 x 150 x 22.50 mm
  • Weight – Display + board only: 268 g; with enclosure: 598 grams

The display can work in standalone mode controlling external hardware through the 8 GPIOs, or connected to an MCU board over serial. You’ll find a few more technical details in the Wiki. The UI designed in Nextion Editor is stored in the flash memory or micro SD card, and the MCU board can receive / send commands to get user input/update the display. Nextion Editor is still a Windows only program, but if my memory serves me well, it can also work with Linux through Wine using a /dev/ttyUSB0 to COM1 redirect.

There are four models: NX8048K070_011N without touch support (no sold for now), NX8048K070 with resistive touch sold for $81.90, as well as NX8048K070_011C and NX8048K070_011R both sold with enclosure, and either resistive or capacitive touch respectively for $88.00 and $108.00. It appears the model without enclosure has been selling for a few months already, and the models with enclosure are new.

Categories: Hardware Tags: display, itead studio, mcu, nextion

Some Sonoff TH16 and Sonoff POW Manufactured in December 2016 / January 2017 Are Being Recalled

March 1st, 2017 29 comments

Sonoff TH16 and Sonoff POW are inexpensive and useful wireless switches based on ESP8266 WiSoC. I’m using Sonoff TH16 to control a water pump, and Sonoff POW to monitor my office power consumption. I received mine in early November 2016, so they were probably manufactured sometimes in October. Does manufacturing month matter? Yes, it does, as ITEAD Studio has just issued a recall notice for both devices for a batch manufactured between December 2016 and January 2017.

The problem is that while the switches come with a 16A relay, the trace were not thick enough, and if you connect a device that draws enough power, they would heat enough to make the case slowly melt. The problem is that ITEAD Studio asked the factory to add “sufficient tin to the wires to ensure low enough impedances”, but they did not quantify it clearly, and that’s why the product is not safe to use.

If you are affected, the good thing is the company owed their mistake, and you can contact the company for a refund or replacement by providing a photo or video, as well as your order number. What they did not say exactly is how to identify a product with the defect, that is before it melts…

In order to avoid the issue in the future, they’ve “optimized their workflow”, and “are seeking for better solution to improve the product during the manufacturing process”.

Karl’s Home Automation Project – Part 1: Home Assistant & YAML, MQTT, Sonoff, and Xmas Lights

February 27th, 2017 30 comments

Karl here. I am here to write about my home automation project. First thing I want to say is that I am very cost conscious and I don’t mind putting in extra effort into the setup of things to keep costs down. I did invest a lot of time and had to do a lot of reading to get my project going. It took while and I received a lot of groans from my wife while testing. I am still in the process of tweaking things.

I started watching a series of videos on YouTube from Bruh Automation. He introduced me to Home Assistant. It got me really excited. He uses a Raspberry Pi as a server but I already had a Wintel Pro CX-W8 Smart TV Box which I use as a server. I run 3 Minecraft Servers, Emby Server, iSpyConnect DVR (2 IP Cameras), Unifi wifi controller, and now MQTT Server, and Home Assistant. Below is screenshot of mostly idle.

If it weren’t for iSpy it would be around 5-10% most of the time. Emby transcoding is the only thing that is stressful and it is not used much. The reason I mention this is because after purchasing a Raspberry Pi with power supply and case, you are not far off from getting a z8300 box. Only downfall is dreaded Windows update auto reboot. I finally looked into it and disabled it. If you decide to use a Windows box, I would make sure you are running 64bit windows. One advantage to using a Raspberry Pi is there is an image on Home assistant with the basics pre-configured and just need to write it to an SD card.

Server side Setup

I won’t go into too much detail on server side, as I installed Python, Mosquitto, and Home Assitant (I followed the guide on their site for Windows)

Python was a breeze to install and just ran the executable and went with defaults. I already had it installed for something else and I am running 3.5.2 64-bit. There are newer versions now. Mosquitto was the most difficult. I followed this guide but substituted Win32OpenSSL_Light-1_0_2j.exe approx 2MB. A k version is available now. Home assistant was easy and used pip.

Christmas Lights

It was a little before Christmas when I started researching home automation. I had been reading about these inexpensive Sonoff devices here on CNX and I found a project on Github for some custom firmware by arendst that enabled them to be controlled by MQTT. (While getting the link it looks like a new project has started with some additional features here). My wife really likes decorating for Xmas and we have 3 trees and lots of lights. She mentioned getting some timers and boom I had my opportunity and ordered them the same night. After receiving It took me a couple nights and I had a simple automation turning Xmas lights on and off at specific times and life was good. I got an extra one to play with until Xmas was over. I redeployed the rest  around the house after Xmas.

MQTT

I really had no idea what this was and it took me a while to grasp. You can use a cloud based MQTT if you would like, but I prefer to run my own. MQTT is a service that relays messages between devices. There are 2 main items topics and payloads. To be able to tell a switch to turn on you send payload “on” to a topic, for example, “cmnd/testbench/power”. The light turns on and it replys back to a topic “stat/testbench/POWER” confirming that the light is on and the message is received. Because we are sending “on” to the topic each device using MQTT will need its own topic. Topics are case sensitive. I made a batch file to subscribe to all topics for troubleshooting so I could monitor the messages. The # indicates all sub topics.

Sonoff

I picked the Sonoff basic but there are also different varieties that add additional features which are supported by arendst software.

Arendst  has been very active with this project and adding/tweaking daily. When I first flashed the device, I did find a defect and notified him and he had it fixed and uploaded within the hour. He has very detailed instructions on the Wiki. First step before flashing is soldering headers. (I link to bent headers…which I initially thought I made a mistake but turned out it was good. They are easy to straighten) A USB to TTL adapter is also needed to upload from Arduino IDE. I recommend one like this because it provides both 3.3 and 5V.  After downloading and setting Arduino up, I only set my WiFi password and SSID in the sketch. After it boots the first time, it connects to your wireless network. Find the IP address in your router, and pop the IP address in your browser to finish the configuration. Set the MQTT server credentials and topic and your done. I never setup credentials on the MQTT server so it accepts any login. Finally after everything is programmed you need to connect it to mains. Beware do not connect mains while TTL is connected.  I bought some extension cords locally. Cut them in half and stripped back a ¼ inch of the insulation. Extension cords use stranded wire so I tinned them with solder to avoid any stray strands from shorting out. Then I screwed them down on the terminals making sure polarity was correct.

Click to Enlarge

YAML

YAML is unforgiving. It is the formatting that you configure Home Assistant in. A single space will stop Home Assistant from starting. Luckily on this last update if you restart Home Assistant through the browser it will test the configuration file before actually restarting. I purposefully put an extra space on line 54 to show it is easy to find any mistakes.

Click to Enlarge

I also recommend Notepad++ for editing in windows. You can break your configuration down into different files but I like one. Notepad ++ allows you to collapse the parts you aren’t currently working on.

I recommend adding one thing at a time and restarting to make it easier to find errors. And making a copy of the last working config before adding more. In the config below there are 5 sonoff’s and an automation to turn the lights on and off at specific times. This is extremely basic. I also recommend setting up one new device and be conscious of naming. When you get your config working properly on your first new device I copy the config to a new blank text window and do a find/replace.

Below is the screen capture of collapsed parts, and and full config (minus personal info).

Notice the test bench is on later firmware and the MQTT topic is slightly different

Next Steps

So now I have a smart home, right? Not in my opinion. I can turn lights on and off with a schedule or with my smart phone or at the light by pressing the button on the Sonoff. To me this is not smart. Setting a schedule is OK, but then you have the lights on unnecessarily and wasting electricity. Only real option is to press a button on the Sonoff but what difference is that than flipping a switch. Taking your phone out takes way too long, and I feel like it is going backwards. Below are estimated costs so far. By far the Windows Box will be the most expensive part if you choose to go that way. You can re-purpose just about anything that runs Linux to be a server. One other option is to run Linux on an S905x.

Money Spent

Cost of server not included nor shipping.

Item Qty Price Total
Sonoff Basic 5 $4.85 $24.25
Headers 1 $1.50 $1.50
USB to TTL 1 $2.54 $2.54
Total $28.29

If you find this entertaining or want me to go more in depth on a specific aspect let me know in the comments. I have been finding my time setting it up very satisfying. I am able to do some hardware and software work. I hope this might get your interest in home automation going, and find out it is not hard nor expensive. I would like to state none of the products linked were provided by the sites. I purchased with my own money.

The plan right now is to do a 3 part post. In the next post, we will integrate some inexpensive motion sensors and door sensors using 433mhz, then finally modifying the sensors to include a light intensity sensor.

Continue reading “Part 2: 433 MHz / WiFi MQTT Bridge, Door & PIR Motion Sensors“.

Sonoff SC WiFi Environmental Monitor mini Review

December 21st, 2016 6 comments

Yesterday I received two environmental monitors with Sonoff SC and vThings CO2 Monitor, and while I’ve plugged both, I have not had time to look into vThings documentation, but since I’m already using eWelink app for Sonoff TH16 wireless switch, setting up Sonoff SC just took me a few minutes, so I’ll report my experience with the device in this review.
sonoff-sc-usb-power-modemI powered Sonoff SC using the USB port of my modem router, and the green LED on the back of the device started to blink every 2 or 3 seconds. Then I started eWelink app in my Android phone and taped on the “+” icon to add a new device following the instructions here which are basically the same for all Sonoff devices.

Click to Enlarge

Click to Enlarge

Then you need to press the “Audio” button for about 5 seconds until the green LED blinks faster, at which point you can click Next, configure connection with your WiFi router, and complete registration by giving it a name, such as “Air Quality Monitor”.

Click to Enlarge

Click to Enlarge

Now Sonoff SC will show with your other Sonoff devices in eWelink app and show the air quality level, temperature, humidity and noise level. You can click on the > button to get to the prettier representation of the data as shown on the right screenshot above. The data was matching reality as the temperature was about 20 C at the time, and since it was still early morning, humidity was high.

Click to Enlarge

Click to Enlarge

I started to talk a bit loud, and Noise level changed from quiet to Normal. However when I turn on a headlight in to the top of the device, the light intensity was still at dusky… I took at screenshot a little later in the morning and the temperature had risen to 24°C, while humidity lowered to 53% normal, matching reality although probably not perfectly accurate due to the sensors used (e.g. DHT11).

Beside reporting data to the app, Sonoff SC can also be used as a smart hub to control other Sonoff devices. You can create “Scenes” by tapping on “…” icon in “All Devices” window, and add a condition (trigger device) using sensors from Sonoff SC or other Sonoff devices shown as “Air Quality Monitor” and “Water Pump” in the screenshot below.

Click to Enlarge

Click to Enlarge

However, while I could setup a trigger device (Sonoff SC) using the temperature data, I was not able to add an “Execute Device” despite having a Sonoff TH16 wireless switch registered with eWelink app and set in manual mode (e.g. not using external sensors to trigger it on or off).  I have a temperature and humidity sensor attached to Sonoff TH16, so maybe that’s why.. It might be only categorized as a “trigger device” and not an “execute device” despite also coming with a relay. I’ve contacted the company to see if there’s a solution.

Sonoff SC is sold for $19.99 + shipping directly on ITEAD Studio.

How to Use Sonoff POW ESP8266 WiFi Power Switch with MQTT and ThingSpeak

December 11th, 2016 11 comments

ITEAD Studio’s Sonoff is a family of cheap home automation products based on ESP8266 WiSoC, and I’ve already tested Sonoff TH16 wireless switch with a humidity and temperature sensor using the stock firmware and eWelink app for Android or iOS. It works, but up to recently it required a registration to a cloud service (the company will now allow use from the local network), and the source code is closed. So for the second device under review, namely Sonoff POW wireless switch with a power consumption monitor, I decided to install ESPurna firmware working on ESP8266 Sonoff devices and NodeMCU, as it’s open source, supports Sonoff POW natively, includes a web interface to control the device from the LAN, and includes an MQTT client.

MQTT (Message Queuing Telemetry Transport) is a lightweight publish/subscribe messaging protocol used to control IoT sensors and devices, and it’s a popular method to gather data from client to a MQTT broker to push the data to the cloud or a local database.

iot-sensors-mqtt-cloud

So typically, you’d have a bunch of sensor nodes (like Sonoff devices) communicating over MQTT to an MQTT Broker in your local network, which could be an OpenWrt router or a Linux development board like a Raspberry Pi, which in turns gets the data the the cloud to services like AWS IoT, Xively, or ThingSpeak. It’s also possible to use Cloud services to control MQTT devices remotely through the MQTT broker.

I eventually plan to use NanoPi NEO board to run both MQTT and ThingSpeak locally (not connected to the cloud) in order to monitor the power consumption of my small office, but since I’m all new to this, I’ve started experimenting by connecting a 30W light to Sonoff POW, and use a desktop computer running Ubuntu 16.04 for MQTT and ThingSpeak.

sonoff-pow-connection

Click to Enlarge

Click to Enlarge

Since I’ve already installed ESPurna firmware to the device, I disconnected the USB to serial board (important since Sonoff POW board has a hot ground), and connected it to the mains (220V in my location). That means we already have an MQTT client which first I had to configure.

Click to Enlarge

Click to Enlarge

Since it was the first time I connected a load to the device, I went to ESPurna’s status menu to check power usage was reported, and my 30 Watts light bulb was drawing 27 Watts. Close enough. I changed the hostname to sonoff-office, and setup two SSID in order to connect Sonoff POW to my local network in client mode, instead of using it in Access Point mode by default. You’ll need to tap on Update each time you modify the settings. Since the SSID must be entered manually, please note that SSID are case sensitive, e.g. CNX-SOFTWARE is different from cnx-software.

Click to Enlarge

Click to Enlarge

I wanted to calibrate the power using the 30W light bulb, so I entered 30W in AC RMS Active Power field, and tapped on Update, but the web interface reported “no changes”. I’m not sure how to use that part. Finally the most important part for this tutorial is to set the MQTT settings with MQTT IP address, and leaving other fields unchanged. However, you can change MQTT Topic field for example replacing /test/switch/{identifier} by /myiotstuff/{identifier}.

Now that our MQTT client is configured, I need to install mosquitto MQTT broker in Ubuntu:

mosquitto-clients is not really needed, but I’ll use it to test the MQTT broker a little later. Once you installed it, the MQTT Broker should already run automatically.

The last line of the log above shows a client connection from Sonoff POW. Now, we need to check the topic, and since ESPurna documentation is still work in progress, you could either check out the source code, or IMHO more fun, capture MQTT packet with tcpdump or Wireshark as I’ve done below.

Wireshark MQTT Capture - Click to Enlarge

Wireshark MQTT Capture – Click to Enlarge

Here we can see that Sonoff POW will send a Publich Message with the power level using the topic “/test/switch/sonoff-office/power29”.  “/test/switch” is the string we’ve defined in the web interface, “sonoff-office” the hostname we’ve given to Sonoff Pow, and “power29” indicates 29 Watts of power is currently used.

We can also start a client in Ubuntu 16.04 terminal window to check more MQTT topics with # wildcard for sonoff-office host:

We can use MQTT to get the IP address, firmware and file system version, hearbeat message, power use, and relay status (on or off).

It’s all good, but now we need to do something to draw the data, and possibly analyze it. I selected ThingSpeak for this purpose since it can be installed in the local network, or through their service in the cloud. By the end of my testing, I’ve noticed ThingSpeak has a new MQTT API, meaning it should be possible to connect your MQTT broker directly to it, but for this guide I use mqspeak instead as a bridge between MQTT and ThingSpeak. It may still be useful, as the open source version of ThingSpeak is not updated anymore, and lacks the MQTT API.

You’ll need Python 3 and pip3 to install mqspeak:

Once it’s done, we’ll need to create a config files as explained on mqspeak’s github repo, and I created /etc/mqspeak.conf with the following content:

Brokers are used to configure MQTT broker IP address and port, as well as the topic(s) to subscribe to, while Channels take care of ThingSpeak configuration with the channel’s Id and write API key, update rate in seconds (15s minimum), update type (see github for details), and fields defined in your ThingSpeak’s channel(s), which will create later on. I wrote one broker for the power consumption topic, and other for the relay status. However, I eventually ignored the relay status, as it’s not updated often enough and cause ThingSpeak’s channel to only be updated when the relay changes status, even if there are power updates in the meantime. A workaround is to use two different channels for ThingSpeak.

mqspeak connects directly to api.thingspeak.com, so if you are using ThingSpeak cloud services, the next step is to register an account and setup one or more channels.

Extra Instructions for a local installation of ThingSpeak

However, if you’ve installed ThingSpeak in Ubuntu 16.04 or other Linux operating systems locally or on your own server, you’ll need to change the server in the source code, and reinstall mqspeak.

  1. Get the source code:
  2. Modify mqspeak/sending.py to replace api.thingspeak.com using HTTPS with localhost (or other IP address/URL where you’ve installed ThingSpeak) with HTTP:
  3. Install mqspeak

An improvement would be to install a signed SSL certificate, like the one offered by LetsEncrypt and configure the rails server to use https instead. I have not setup ThingSpeak server to start automatically yet, so I have to start it manually for now:

End of instructions specific to local installation.

The instructions specific for the local installation of ThingSpeak are now done, and all instructions below are valid for both the local installation and cloud service. Now open a web browser, go ThingSpeak (cloud or local), and click on “Get Started Now” in order to register an account.

Click to Enlarge

Click to Enlarge

Once it is done, login and click on “New Channel”.

Click to Enlarge

Click to Enlarge

Give it a name, a description, create fields as needed, for example power-consumption and power-status, and click on Save Channel.  Update /etc/mqspeak.conf accordingly with the fields’ name, and channel Id.

thingspeak-api-keyNow select API Keys tab to copy and paste the write API key into mqspeak.conf.

Now we can start mqspeak:

ESPurna firmware will send a power update every 60 seconds (this can be changed in code/src/pow.ino), so you’ll see a new message pop-up every 60 seconds with your channels Id and write API key. I’ve let it run for about one hour, and got the follow chart in ThingSpeak after turning on and off the lights from time to time.
thingspeak-power-consumptionThat’s pretty cool, so it only shows the current power in watt, and we’d probably want to get power consumption in kW/h per day, week and month at some time, and I have yet to study how to do that, Exporting the data to excel would be a workaround if this can not be handled in ThingSpeak. ThingSpeak.com (but not the open source version) offers some Matlab processing of the data, so that’d be another options.

The next steps would be to install MQTT and ThingSpeak in NanoPi NEO board, enable HTTPS in ThingSpeak, autostart rails server and mqspeak at boot time, make ESPurna firmware publish the “Power” topic more often than every 6 second, and find some way to generate useful kW/h consumption charts from the data stored in ThingSpeak within ThingSpeak, or but exporting the data.

Sonoff SC WiFi Environmental Monitor Sells for $20

December 9th, 2016 8 comments

ITEAD Studio has done some good job with their Sonoff home automation devices based on Espressif ESP8266 WiSoC, as they are affordable, working as advertised with default firmware, and hackable with our own. The company has now added a new model, which may or may not be as useful, with Sonoff SC environmental monitor device that detects current temperature, humidity, light intensity, air quality, and sound levels, and sends the data to eWeLink app installed on your Android or iOS phone.

sonoff-scYou may be thinking it can be used as a home assistant since it really looks like a speaker and include some sort of microphone, but the top of the device is probably used to let air and dust go through.

Sonoff SC specifications:

  • WiSoc – Espressif ESP8266 Tensilica L106 processor @ 80/160 Mhz with WiFi
  • MCU – Atmel ATMega328 MCU
  • Connectivity – 802.11 b/g/n WiFi
  • Sensors
    • Sharp GP2Y1010AU0F dust sensor to detect smoke and dust
    • DHT11 temperature and humidity sensor; Range: 0 to 100 °C
    • GM5528 photo-conductive resistance
    • Electrat condenser microphone
  • Power Supply – 5V via micro USB port

esp8266-environmental-monitor

The default firmware and eWelink app also allows to set various smart scenes to trigger other devices, for example if air quality is too poor, Sonoff SC could turn on a fan connected to Sonoff wirelesss switch, or lights could be turned on when it becomes dark.

eWelink Environmental Report Card

eWelink Environmental Report Card

But you don’t have to use the default firmware if you don’t want too, as Sonoff SC’s ATMega328 controller can be programed through the Arduino IDE if you want to change the firmware, while ESP8266 is used for WiFi only. You’ll find the schematics (PDF) and Arduino code in the Wiki.

If you are interested, you can purchase Sonoff SC for $19.90 on ITEAD Studio website with shipping adding $7.33 to $17 depending on selected shipping method.