CRITICAL MASS is a huge group ride at the end of every month. People start gathering around 6:30 and arrive at the final location around 10pm. Events like this usually disrupt the flow of traffic.
By leveraging the latest ATT M2X technology and PubNub I was able to create a possible solution to this issue....
Create a solution that will allow riders to be connected with each other and allow them to work in synergy. Riders can have an IOT device that communicates with the swarm. They can now be informed when to stop and go, or receive a variety of messages and alerts. This was achieved by using the ATT StarterKit & other IOT Hardware...
Introducing the SWARM APP built using Angular & PubNub:
The SWARM app is a Chatbot that supports the following commands:
- INFO - Get latest ride details
- ALL - Turns all LEDS on for 5 seconds
- ALL ON - Turns all LEDS on
- ALL Off - Turns all LEDS off
- PHOTON - Turns all Photon Group LEDS on for 5 seconds
- WIO - Turns all WIO Group LEDS on for 5 seconds
- SENSORS - Get all sensor values (Humidity, Air Quality, UV Light, etc)
- PLOT [LATITUDE] [LONGITUDE] - Save data to M2X and update EON Map
Future enhancements may include:
Social Media login, Group/Individual Chat, Get list of previous rides, Get best ride (sunny, shady, smooth surface, etc)
Application flow:
Here is how to get started...
Get some IOT boards that can be connected to the internet, or that have a REST api. I chose the Photons and the WIO Node (ESP8266), both can be programmed over WIFI. At the core of the project is the ATT starter kit, which comes with a WNC shield and SIM card, which make connecting to the internet a breeze.
Prototype BOM:- 1 x ATT StarterKit
- 2 x Particle Photon + w/LEDS + w/Sensors
- General: Breadboards, wires, batteries
The WIO's can be configured via the WIO Mobile app.
After configuring the WIO, you can simply use their REST API to access the components. Here is what it generates for you:
//Sample GET for AIR Quality sensor
https://us.wio.seeed.io/v1/node/GroveAirqualityA0/quality?access_token=xyz
Next step was to configure the Photons. I used the CLI for the setup.
After the Particles are configured, you can then write code to expose the Functions via a REST api. Here is a sample GET command to turn on the LEDS:
https://api.particle.io/v1/devices/2b003b001247353136383631/led?access_token=XYZ
I used POSTMAN extensively to test and debug any REST API...
This may take a few steps, but should be straight forward if you follow their guide: https://s3-us-west-2.amazonaws.com/starterkit-assets/StarterKitGuide-V1.2.pdf . Here is the setup process as outlined by ATT:
I used Jackery powerbank as the power source. Here is my setup prior ti adding any other components:
There are 2 main pieces of software you will need:
- mbed on IDE (send data over ATT SIM)
- Angular JS with PubNub, Bower, Grunt, Brackets (CHAT BOT interface)
Much of the logic is handled in Flow Designer, which is abased off Node-Red . This allows you to use write some of the logic in JavaScript.
I used 2 PubNub Channels:
- "swarms" - is used for all general chats
- "swarm-map" - is used to store the Mapping content (lat & long, marker, etc)
Events come through the 'swarms' channel then sent to M2X via the REST api.
Values are stored/saved onto ATT's M2X via the Web API.
MapBox is used for the maps. It allowed for quick integration with PubNub.
Here is the progress thus far:
Will continue to refine the project into a fully working prototype.
Work In Progress:
- Hardware: Add GPS module
- Software: Add Social Media login, Build out more CHAT features
- Use PhoneGap for mobile app.
Learned a lot from building this proof of concept. First time really using M2X. ATT has built a really great tool-set for integrating a variety of systems. I look forward to using this tech stack again on my next IOT project. Thanks ATT & Hackster!
Comments