This is the 10th of my Blogs for the Bluetooth Unleashed Design Challenge
The other posts are here :-
Concept
The idea is to detect the bluetooth transmitted from the vehicle and signal other Home Automation functions.
If the vehicle is known then it can open the garage door, and inform the home owner that xx is home.
Hardware
The detection point needs to be at the start of the driveway, and because there is no power source, this will need to be low power with solar charging.
The PSOC range seems a very good fit, but because of the timeline and my need to upskill, the inital design will be Arduino based and some form of RF transmitter/transceiver.
Adding a vehicle detection loop or beam is necessary to ensure those vehicles without bluetooth will also trigger the system.
Notifications
During the plan, I eluded to providing notifications.
In my application I wrote :-
If the system doesn't recognise the vehicle, it can :-
- trigger a survelliance camera to record video and take snapshots.
- turn on the outside lights
- inform the houseowner that they have visitors
- Send a notification to a smartphone
This system also can record when someone visited and for how long, which may prove useful if they have been up to no good.
For informing the houseowner, I've been doing some thinking about something that is suitable, and easily conveys what is required.
I intially had a plan to use another RaspberryPi and touchscreen to bring up a message.
While this was a possibility, the location within the house needed to be a comprimise, and would not always be useful.
(A bit like the cordless phone that lives on the charger ... and you aren't near the charger)
As I thought more, I looked at our Internet of Holidays Suppliment Internet of Holiday Lights RoadTest Plus (suppliment)
In that Jan Cumps and fvan created a "I'm home" style indication using MQTT.
You can read about it here
[Christmas Wreath of Things] Internet of Holiday Lights: part 10 - Secret IoT Team Up
[Christmas Tree] Internet of Holiday Lights - Special Feature
It became an open invitation, but I suspect things have moved on, and no-one is subscribing.
Internet of Holiday Lights: Join the secret IoT Service - open for all
MQTT and a small micro just might solve my issue.
It was interesting to read the design principles for MQTT.
https://github.com/mqtt/mqtt.github.io/wiki/Design-Principles
ESP8266 or ESP12
This approach using MQTT would suit having multiple indicators around the house, and could even be portable if you wanted.
By using an ESP device, the need for an ethernet connection disappears.
Hence I searched for ESP8266 and MQTT.
https://techtutorialsx.com/2017/04/09/esp8266-connecting-to-mqtt-broker/
https://www.esp8266.com/viewtopic.php?f=29&t=8746
The ESP8266 requires the PubSubClient library which can be downloaded from here :-
https://github.com/knolleary/pubsubclient/archive/master.zip
We've seen a few examples of NodeRED and MQTT, but it seemed an overkill to have to install it just to send a message.
https://randomnerdtutorials.com/esp8266-and-node-red-with-mqtt/
In the meantime I've had a play with ESP8266 and neopixels.
I found this very good post https://www.hackster.io/thearduinoguy/esp8266-neopixel-ring-clock-a9cc74
With a bit of tweaking and a 12 neopixel ring, it makes a very useful object.
/* Sketch to run a ESP3266 driven by time. This displays on a 12 x neopixel ring The colors of the 'hands' are: RED = Hours GREEN = Minutes BLUE = Seconds credit to https://www.hackster.io/thearduinoguy/esp8266-neopixel-ring-clock-a9cc74 TimeClient.h can be obtained from https://github.com/squix78/esp8266-weather-station Extract the TimeClient.h and TimeClient.cpp files and add them into the sketch folder (hence the "TimeClient.h") Mark Beckett */ #include <Adafruit_NeoPixel.h> #include <ESP8266WiFi.h> #include "TimeClient.h" #define PIN D5 int ledsInString = 12; long lastUpdate = millis(); long lastSecond = millis(); String hours, minutes, seconds; int currentSecond, currentMinute, currentHour; char ssid[] = "your SSID"; // your network SSID (name) char pass[] = "your password"; // your network password or simply "" if there is none const float UTC_OFFSET = 12; TimeClient timeClient(UTC_OFFSET); Adafruit_NeoPixel strip = Adafruit_NeoPixel(ledsInString, PIN); void setup() { Serial.begin(115200); Serial.println(); Serial.println(); strip.begin(); strip.setBrightness(128); strip.show(); // We start by connecting to a WiFi network Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, pass); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); timeClient.updateTime(); updateTime() ; lastUpdate = millis(); lastSecond = millis(); } void loop() { if ((millis() - lastUpdate) > 1800000) updateTime(); if ((millis() - lastSecond) > 1000) { strip.setPixelColor((currentHour * 1), 0, 0, 0); strip.setPixelColor((currentMinute / 5), 0, 0, 0); strip.setPixelColor((currentSecond / 5), 0, 0, 0); strip.show(); lastSecond = millis(); currentSecond++; if (currentSecond > 59) { currentSecond = 0; currentMinute++; if (currentMinute > 59) { currentMinute = 1; currentHour++; if (currentHour > 12) currentHour = 0; } } String currentTime = String(currentHour) + ':' + String(currentMinute) + ':' + String(currentSecond); Serial.println(currentTime); strip.setPixelColor((currentHour * 1), 255, 0, 0); strip.setPixelColor((currentMinute / 5), 0, 255, 0); strip.setPixelColor((currentSecond / 5), 0, 0, 255); strip.show(); } } void updateTime() { hours = timeClient.getHours(); minutes = timeClient.getMinutes(); seconds = timeClient.getSeconds(); currentHour = hours.toInt(); if (currentHour >= 12) currentHour = currentHour - 12; currentMinute = minutes.toInt(); currentSecond = seconds.toInt(); lastUpdate = millis(); }
Contrary to popular belief, you can drive the neopixels directly from the 3v3 GPIO of the ESP8266.
I did have to download the latest library from Adafruit.
https://github.com/adafruit/Adafruit_NeoPixel
I swapped the order that the pixels are driven so the second hand has priority and overrides the minutes or hours.
The time is currently 17:35 and 0 seconds.
I guess at some stage a different colour when they illuminate the same pixel might be nice, but in the meantime it works.
The ultimate clock would be the 60 ring neopixel and it's very tempting to do some online shopping ....
My intention is to change the display to all green or all red to warn of impending visitors.
in the meantime the clock display gives some assurance that it's connected and working.
MQTT Server
Luckily you can run your own server on the Raspberry Pi, which means any messages can be kept within the home network.
I found this article which explained the process and how to do some testing.
https://diyprojects.io/mqtt-mosquitto-communicating-connected-objects-iot/
I also found this which IMO was much easier to run and install.
It even included a very simple test using the localhost rather than the internet.
https://www.raspberrypi.org/forums/viewtopic.php?t=125532
So now that I seem to have a local Mosquitto running, I'm ready to do some coding on the ESP device.
Smartphone
My quest to send a SMS to a smartphone has been less than ideal.
We don't run our phones with data, or even WiFi on. We'll turn it on as required, and then turn it off again.
There are many reasons, but battery useage is one aspect, and besides I have a phone to ring people, although texting is the other option.
The last thing I need is beeping, burping and all the other noises whenever someone liked a post on FB, or the temperature changed, or some other trivial event.
Hence my quest was for a means of sending an SMS to a phone or phones.
While there are plenty of free services around, it seems the New Zealand Telcos have blocked any messages that originate outside New Zealand.
I guess it reduces spam, but I suspect it is more to ensure their own service has to be used.
Telecom runs eTXT, and while the monthly charge might be reasonable, the setup fee is a rip-off.
Vodfone had a great affordable service, but clearly that had to change.
And clearly it did. Again the monthly fee bordering on reasonable, but the setup fee is a rip-off.
I did find one service in New Zealand, signed up and tried it out.
All that effort to find out that it relied on advertising revenue, and it hadn't had any, so it couldn't/wouldn't send the SMS.
GREAT ... worse than that, there is no way to unregister.!
While I have no issues with the per text charging, for this project these prices are just not sustainable.
I could purchase a mobile, get a SIM card and send them without all this cost.
I do have a TStick that is designed for data, and I'm wondering if you can use it to send texts?.
Regardless of that, I've decided that I will not be doing this aspect of my proposal.
It does not mean that it wouldn't suit someone else.
I looked at had different methods, apps or ways to send the SMS on some of the sites, and they all seem t be different.
You could even scrap the page to gather the information and use one of those free services.
If I posted details it could be misleading, and I can't prove it works.
Hence I'll raise it during the summary.
Mark
Top Comments