Categories
Electronics

ESP-Link on Bee-ESP8266

Wifi Bee-ESP8266 with ESP-Link.

The module comes with an AT command interface. Use that to connect to your WiFi, eg switch in “BOOT” setting, serial at 115200 8N1 and use the command AT+CWJAP=”<SSID>”,”<PASSWORD>”. Module needs CRLF for line endings. Then disconnect the module. Prepare esptool.py command line eg “esptool.py –port /dev/tty.usbserial-A1017IE0 write_flash -fs 32m -ff 40m -fm qio 0x00000 boot_v1.6.bin 0x1000 user1.bin 0x3FC000 esp_init_data_default.bin 0x3FE000 blank.bin” (replacing serial port for the correct one for you), switch switch to UART, reconnect module and run the esptool.py command. It should flash successfully. Power off the module, switch switch back to BOOT, reconnect power and hopefully the module will boot and connect up to your WiFi running ESP-Link.

Categories
Electronics

Touch/openHab controlled bed lights

I have a couple of 12v LED lights on my bedhead. I think they’re designed for use in caravans or something. They have a switch on their bases so they are pretty easy to install/use. But lights by themselves like that are pretty boring. They are much more interesting/fun if they are computer controlled :-). They are 12v (or 24v) and only draw a couple of hundred mA so are pretty easy to switch with the likes of an Arduino with a relay or a MOSFET (or even a plain old transistor). That just leaves how you tell the Arduino to turn the light on or off. Only via smartphone is rather annoying when all you want to do is reach over and turn the light on. So my first thought was a box with buttons on it (didn’t want to alter the lights themselves). But where do you put it? And it’s a bit messy. Then, recently, I thought why don’t I use one those capacitive touch boards and turn the light itself into the switch. Since I had two lights I bought breakout board with 5 sensors on it. The board works pretty well, the issue being that the wire connecting the board to the light also becomes a touch sensor. To fix this issue I bought two single sensor boards instead. A short wire connects the board to the body of the light.

So for each light I put one of the sensor boards in a small box, mounted it on top of the board the light is mounted on to and ran a wire out of the bottom to the light body. The output of each board runs to an input on an Arduino.

In a box is an Arduino with some shields stacked on it:

The Arduino watches the inputs that the touch sensors are connected to. If the input activates and then deactivates in less than half a second then it toggles the light state and reports the new state over the XBee module. The maximum touch time to toggle is so you can move the light without toggling it. The Arduino also acts on commands received via the XBee module. At the other end of the XBee connection is a Python script that bridges between a number of XBee modules and MQTT. The two lights have been added to openHab as switches via MQTT so their state can be monitored and controlled via any openHab interface.

Categories
Electronics

WiFi Bacon/Ham Machine

At work we get a free packet of bacon (or something else they have heaps of to get rid of) per week, and at Christmas a free ham. So people could self-record their taking of their allocation I built the “Bacon/Ham Machine”. The original one is an Arduino, a 20×4 LCD screen, a MiFare reader/writer to read our door access cards/fobs, and a LED button or two in a box connected to a computer via USB. The smarts were originally handled by a python script but it was re-written in C# .NET in the form of a Windows service. It was first used for recording the ham given out at Christmas. The ham that year was distributed from the factory shop. After that first use it moved onto its Bacon recording use (in the factory shop). The next year the ham was distributed outside (from a chiller truck) and the Bacon/Ham machine was moved outside for the job, connected to an ALIX SBC (running Linux) with power and network cables run out from inside. Obviously that was less than ideal as bacon couldn’t be recorded while ham was. After that a different device was used a couple of years, still with cables running out from inside, and one year just a manual system was used.

So for Christmas 2016 I decided to make a battery operated WiFi connected portable ham recording device. It operates similarly to the previous devices in that it is fairly dumb device with the smarts running on a proper computer. It just opens a simple TCP connection to a program running on a “proper” computer that tells it what to display and what buttons to light up, and it tells the program the ID of a fob when one is read and when buttons are pushed. I used:

Powering the LED on the switch was interesting as the M0 CPU used can only sink/source a tiny amount of current so I fell back to my old standby, a ULN2003 darlington transistor array IC. As this switches the negative side and the M0 has internal pull-ups on the GPIO inputs this led to quite a messy switch wiring (common negative for the switches and common positive for the LEDs). In retrospect I should have just used some individual transistors for the switch LEDs so I could have switched the positive side, but I was in a bit of hurry. The box was also a bit small for all the stuff I put in it, hence why one of the switches is different as the ones with the LED just wouldn’t fit.

I had some issues with the WiFi. The examples have a delay(10000) after the WiFi.begin() which adds quite a delay to connecting to the WiFi. I don’t like big delays for no apparently reason so I took it out and replaced it with a loop that exited when the module reported that it was connected. This resulted in much quicker connections to the WiFi but the whole thing would only run for a few minutes at most and then it would just lock up/crash requiring the reset button to be pushed. So I went back to the 10sec delay and then it ran fine. I tried lots of combinations of stuff and only the 10sec delay worked, so I stuck with that. The other issue I had was the module wouldn’t connect to our Meru AP320 access points at work. Thankfully it would connect to the AP1020s as those model APs covered the areas it was going to be used in. I don’t know if it was the AP320 itself it didn’t like or the Virtual Port setup. The AP1020 WLAN ESS profile was set as a Virtual Cell instead. I was going to try setting up a standard ESS profile without virtual port on the AP320 and try that but I never got around to it.

I also had issues with reading the buttons. They worked fine without the OLED initialised, but stopped reading properly when the screen was used. In the end I only needed the one button so got one working and left it at that.