Share My Creation [B4X] Server Room Environment solution using Wemos / ESP8266

A client asked us to research environment monitoring options for their server room. The servers
themselves have that built-in but they needed something for the room in general. The following is a proof-of-concept (POC) that I came up with using several of the B4X tools to fulfill their requirements.

Later, I'll post the prototype video and details. Basically, taking the proof-of-concept hardware shown here and miniaturizing it to the form-factor required while keeping the same software. This means replacing the Wemos with a bare ESP8266.

The final product will take that prototype and replace hardware and software to fit not only the form-factor but also get it down to the price-point needed. This means replacing any through-hole sensors, resistors, capacitors, etc. used for expediency with surface-mount versions, smaller/better sensors (especially the Smoke Detector, purpose-built PCB's, etc.

So, here are the basics and the B4X tools (along with a few of the inspiration examples/libraries from the forum as links) used...

Sensor Node
  • A Wemos D1 R2 programmed with B4R. Access Point is disabled. It connects to the office network WIFI Access Point. IP Address is static configured in B4R.
  • Power is supplied by a mains-connected (wall-wart) adapter delivering 3.5V to the Wemos.
  • Via timers, it takes readings of each sensor it has periodically.
  • If a Server client is connected, it sends all current readings to it after each sensor reading through AsyncStreams.
  • The Sensor Node makes no decisions. It just reads the sensors and reports those to the Server.
Sensors...
  • Temperature & Humidity: DHT22. Connected to Wemos pin D2
  • Light: A basic resistive Photocell. Connected to a capacitor allowing me to read it via Wemos D3 using the Capacitor Recharge Technique instead of the Analog Line.
  • Smoke: A cheap (<$5 USD) home smoke detector. The normal 9V battery is used ONLY for the smoke detector. NOT the Wemos. Connected to Wemos pin A0 and reading the voltage of the wires going from the Smoke Detectors sensor to the alarm buzzer. Not reading the smoke sensor directly, rather, the alarm buzzer.
  • Water/Flood: Just 2 wires that are bare on the ends and separated a few inches that reach the floor. Connected to a capactitor allowing me to read it via Wemos pin D5 using the Capacitor Recharge Technique instead of the Analog Line.

Server Computer
  • A Linux / Windows / Mac /RasPI computer running the B4J non-ui Server app.
  • Maintains a list of the Sensor Nodes it needs to connect to via the Static IP Addresses assigned to each Sensor Node.
  • Connects to each Sensor Node via Sockets and, if it looses the connection, re-establishes it.
  • Clients connected to the Server via Websockets to automatically get Sensor Node updates sent to them as those readings come from the Sensor Nodes.
  • The Server makes all of the decisions based on the received readings from the Sensor Nodes. For example, sending emails, texts, unlocking doors (via relays and other methods), starting/stopping equipment (again, relays) if water/flood or smoke is detected.

Client (Android)

Widget...


  • Uses B4A to show the Temperature, Humidity readings and icons for Light, Water/Flood and Smoke detectors. Multiple Widget inspiration here.
  • It connects, via Websocket, to the Server where it calls a Sub for any current readings for the Server Node that that Widget is monitoring then closes the connection to the Server.
  • The Widget re-starts itself after X number of minutes to get updated information from the Server.
  • The user can click on the Widget to choose a different Sensor Node to monitor from that Widget.
  • The user can also click on the Widget to open the Client App.

App...

  • Uses B4A to show all readings for all Sensor Nodes monitored by the Server.
  • Clicking on the Sensor Node shows the last 50 readings in a line chart at the bottom.
  • The App connects to the Server via Websocket and re-establishes the connection if broken.
  • The Server sends periodic updates to the Sensor Node readings as those come in from the Sensor Nodes.
  • At this time, there is no command/control of the Server or the Sensor Nodes from the Client although that is the next step in this test project.

Client (Webpage)
  • Uses B4J Server Handler to feed a simple webpage. Inspiration here.
  • Connects to the Server every X seconds through a simple webpage via the Server Handler and downloads the last 50 readings to be viewed by Google Charts.
  • This is used just for my own testing purposes although it could be used as a browser-based interface for anything the other Clients are doing with more development.

This project does a few things differently than what's been shown on this forum and projects from various places on the 'net, too (Mains-connected power, Separate Power for the Micro-controller and Smoke Detector, Direct TCP connection from Server to Nodes instead of Node UDP Network Broadcasts, No Message Broker (MQTT) usage, etc). These were conscious decisions based on the required project specs. Different circumstances might require those things.

Hardware costs for the POC are under $20 USD and the prototype is under $13 USD with the Final Production unit at $? USD. Software and R&D: Priceless.

A long video of everything splayed-out like a gutted fish to show everything. While this POC version doesn't fit into the smoke detector, the prototype does. And the production version fits with room to spare.

I'll try to answer questions about it as I have the time to do it. I won't be sharing code until 1) The production version is finished up by that team. 2) I have time to support the code.


 
Top