Announcing the "ST_Anything" Arduino/ThingShield Project

@digadv Glad you were able to get it up and running quickly!

Just curious… Did you start with the ST_Anything_AlarmPanel_ESP8266WiFi.ini example sketch? The reason I mention this is because that sketch was tested to make sure the NodeMCU ESP8266 board would still flash/boot properly with all of the magnetic reed sensors attached to the pins assigned in the sketch. Please pay attention to the chart I added to the bottom of the ST_Anything ReadMe file which shows my findings of the NodeMCU ESP8266 GPIO pin limitations to be aware of.

Dan

For my project, I’m leaving the alarm panel alone and using a couple of programmable outputs on the panel to trigger ST. I did see the notes you mentioned however.

Again - great work on this project!

1 Like

Dan - thanks so much for doing this. I successfully installed everything onto my Mega board with the 5100 shield. All I have working right now is a simple button linked to a digital pin for a contact child device. It shows up in the app as closed when I hit the button so I know its all wired up right. Now the sky is the limit… going to build a custom control panel with physical buttons, dials, LEDs, and Illuminance sensors to control my most common things. I assume I can use the state of any child device as the trigger in a smart app right? I couldn’t find a dimmer child device - is there one?
[EDIT:] Never mind, I found it in the folder. It just wasn’t used in the multi example file.

Now that I have my Mega board working, I want to move it to WiFi. I just placed an order on Amazon - only $13 for four of these. Seems too good to be true. Hope they work. So when it arrives, do I just start over with the sample ST_Anything_Multiples_MEGAWiFiEsp file to write my sketch?

Yes, exactly. There are only a few minor differences between the sketches for the type of communications being used. If you’re using an ESP01, be sure to provide it with a good 3.3v power supply as the Arduino’s 3.3v pin is not capable of supplying enough current.

Thanks - sounds easy enough. One other thing… when I install the parent all the children devices get created automatically except I can’t find any associated with the Button devices. Are these done differently? I noticed you have to say how many buttons you have when you install the parent which suggests they are special somehow.

Correct. The Button devices are handled directly by the parent. There are no child button devices, since there are usually no tiles associated with a button. Therefore, the parent just raises the “pushed” and “held” events to any other SmartApps that are subscribed. By setting the number of buttons in the parent app’s settings, you are actually announcing to the world the number of buttons available. This allows apps like SmartLighting and CoRE to present the correct number of buttons.

I modeled the button behavior to mimic the Aeon Minimote. It’s Device Handler has no tiles for each button. Just one generic tile.

got it, and yes that makes sense. I’m now wiring up a light sensor and trying to figure out how to calibrate it with the map settings. So far not much luck. Lux ranges from 500 to about 800 for dark to light room. Guess I could just play with the size of the pulldown resistor until I like the range. Currently using 10K which should give good results. Using R1*V/(R1+R2) i estimate the voltage range to be pretty broad with a 10K. Anyway, if you have any experience with this would welcome advice.

Ken,

Have you figured out the Illuminance sensor yet? It is pretty straighforward. Below is the list of arguments and their descriptions. If you want a larger “illuminance” value, simply increase the last arguement from 1024 to something like 10000. This will scale the analog input’s 0 to 1023 counts (0 to 5v on an Arduino UNO/MEGA) to 0 to 10000 lumens.

//			  For Example:  st::PS_Illuminance sensor1("illuminance1", 120, 0, PIN_ILLUMINANCE, 0, 1023, 0, 1024);
//
//			  st::PS_Illuminance() constructor requires the following arguments
//				- String &name - REQUIRED - the name of the object - must match the Groovy ST_Anything DeviceType tile name
//				- long interval - REQUIRED - the polling interval in seconds
//				- long offset - REQUIRED - the polling interval offset in seconds - used to prevent all polling sensors from executing at the same time
//				- byte pin - REQUIRED - the Arduino Pin to be used as a digital output
//				- int s_l - OPTIONAL - first argument of Arduino map(s_l,s_h,m_l,m_h) function to scale the output
//				- int s_h - OPTIONAL - second argument of Arduino map(s_l,s_h,m_l,m_h) function to scale the output
//				- int m_l - OPTIONAL - third argument of Arduino map(s_l,s_h,m_l,m_h) function to scale the output
//				- int m_h - OPTIONAL - fourth argument of Arduino map(s_l,s_h,m_l,m_h) function to scale the output

yes - I have it sorted out. Your post was very helpful. Now I’m moving on to the ESP01. I have it all wired up as shown using a small board.


I tied the ch_PD and VCC lines together and am waiting to tie that into an external power supply. My question before I proceed is do I need to install any firmware on this thing? Or is the built in AT command set what you use in your library? Once wired up am I good to go? Also, I’m fuzzy on how to wire up an external 3.3 V power supply. I may just use a webcam battery. Any better approach? And why cant the Arduino do this?

The Arduino MEGA’s 3.3v voltage regulator is not rated to supply enough current to the ESP01 module, thus the need for an external 3.3 volt power source.

Yes, I simply use the native AT Firmware on the ESP01 module. I did upgrade the firmware on my ESP01 in order to troubleshoot poor stability issues. But, it turned out to be an issue with the Arduino Serial Monitor baud rate being too low causing timeouts communicating to the ESP01 (i.e. spending too long updating the serial monitor windows text!) I have since changed the baudrate for the Arduino Serial Monitor window to 115,200 (vs 9600) and now the ESP01 works much more reliably as a WiFi shield for the Arduino MEGA. Note: It’s not perfect, but it works pretty well. I have added a lot of error handling to try to automatically recover when the ESP01 has an issue.

Here is how I have my ESP01 wired up. It is basically a copy of http://www.instructables.com/id/Cheap-Arduino-WiFi-Shield-With-ESP8266/

It uses a bidrectional 5v to 3.3v level shifter for serial communications, and a 5v to 3.3v voltage regulator. The voltage regulator is supplied from the Arduino Mega’s 5V source pin which is capably of supplying much more power than the Mega’s 3.3v regulator.

Thanks Dan - this is super helpful. I ordered a bunch of AMS1117 5V to 3.3V regulators to use for this purpose - since they came in a package for a great deal. If I understand right, I use the AMS1117 and capacitor to regulate the voltage for VCC and CH_PD and the resistor voltage split trick to step down the TX voltage from the Mega into the RX pin on the ESP01. Do I have that right?

And do I use the MEGA pins TX/RX 0 and 1 instead of pins 6 & 7 used on the UnoR3 in the example? I can’t tell from your photo which pin you used for TX/RX. I assume the dedicated Modem pins but just checking.

And finally, I am curious as to why one couldn’t use the resistor + capacitor trick to step down the MEGA 5V feed into the ESP-1 instead of using the AMS1117? Is it because of the current load? I’m not very experienced with circuits so just trying to learn here.

Hi all,

with all of the work that Dans has done … Double WOW …
does any one want to part with an original Smart Thing Arduino Shields?

I built a custom motherboard to hold the ThingShield, and now the MB’s and my project is almost useless.

Still looking for TWO more original Arduino Thing Shields to complete this project

I will pay top dollar, $60.00 or $ what would it take ?? each plus shipping

Any assistance is appreciated

Ben

I’m still using mine for my alarm system until I switch over to a newly built Mega board and Dan’s new library and the ESP01 wifi module. After I do that - guessing a month or so - I will have mine available to sell. I won’t need it then. I am curious why you can’t switch over - the WiFi version seems so much more robust to me than Zigbee and not dead end supported. Anyway - if you still need one when mine opens up I will let you know.

Hi Ken, appreciate the callout,

I want to finish the project with these custom PCB’s without having to hack
them,

And at this time I donot know if a Leonardo has enough memory / resources to
speak to an ESP01, or an ESP8266

So easiest for me is to try to find the original Thing Shield to complete
this project.

I am at your timing, let me know when your Thing Shield is available.

Thank Again

Ben

Hrm… new problem now. I am trying to switch to a mega with the thingshield for more pins. When I use the same thingshield and re-pair it with my ST Hub it shows up, I switch the device handler but I am seeing no data at all. No child devices at all ?! I have waited for some time to see what the issue is but nothing. In debug I see all the devices reporting just no joy on the child device handlers?!

Found my own answer on another thread so posting here. Jumper Pin 2 to 14 and pin 3 to 15 on the mega then it works.

Search = my friend :smiley:

1 Like

David,

Glad to hear you figured it out!

Dan

Yes, you can use a simple voltage divider to step down the Arduino’s Tx pin from 5v to 3.3v.

On the Arduino MEGA, my example sketch uses pins 18 + 19 (aka Serial1) to communicate with the ESP01. This is one of the additional 3 Hardware Serial UARTs on the MEGA. These HW Serial ports are much more reliable than trying to use Software Serial and much faster (115200) which is the default for new ESP01’s. Using pins 18/19 also frees up pins 0/1 for use with the Arduino IDE’s Serial Monitor Windows for debug text.

The “resistor trick” (aka voltage divider) is fine for shifting very low current signals from 5v to 3.3v. But you really cannot provide any significant amount of current using a resistor voltage divider. The voltage regulator is designed to step down the voltage and deliver current at a constant stable voltage. The AMS1117 will heat up somewhat so be sure to provide some space for cooling.

Awesome… I have my circuit built and will test in the morning. Just need to rewire the com line to 18 and 19 which means a longer wire. Easy peasy… thanks so much for the advice.