Vaccine Thermometer Backup With ThingSpeak and Twitter Alerts
by hallinen in Circuits > Arduino
193 Views, 0 Favorites, 0 Comments
Vaccine Thermometer Backup With ThingSpeak and Twitter Alerts
Many health care practices are now in the business of vaccinating patients for Covid-19. The vaccines have very fussy temperature requirements, and you are suppose to document the temperature of your refrigerator and freezer twice a day during work days. The CDC has great resources in regards to this...https://www.cdc.gov/vaccines/hcp/admin/storage/index.html
Our problem was the NIST thermometers we had, which were not cheap, was they only did bluetooth. You could buy a device for a couple hundred to have it go over the internet, but come on, a Wemos mini D1 is a couple bucks. Since we have been mostly doing telehealth, we worried that we would find out when it was too late that our vaccines went out of temperature range.
The solution? Two back up calibrated thermometers that sends hourly temperature updates to ThingSpeak which can then send an alert to twitter if the refrigerator or freezer go out of range.
Supplies
WeMos D1 mini. https://www.amazon.com/gp/product/B081PX9YFV/ref=p...
PCB solder board. https://www.amazon.com/gp/product/B08BWPGSSC/ref=p...
One or Two or Three ... DS18B20 thermometer. https://www.adafruit.com/product/381 or https://www.amazon.com/gp/product/B0185OHAR8/ref=p...
One 4.7 K ohm resistor
wire and solder and soldering iron
magnets
Empty hotel size shampoo bottle - cleaned out
Glycerin - you might have it already stashed under the cupboard if you made your own hand sanitizer
Disposable glove, rubber bands, tape, etc.
The Circuit
Really simple. Red lead to 3.3 V. Black to Ground. Yellow to 4.7 K ohm resistor that connects to D4 on the WeMos D1 mini. This corresponds to the GPIO 2 pin. If you are connecting more than one, like I did, they can just hook up to the same resistor. You can learn more about the circuit at Adafruit https://learn.adafruit.com/using-ds18b20-temperatu...
The Code
//I'm assuming you know your way around arduino.
//Red lead to 3.3 V, black to ground, yellow to 4.7 K resistor that goes to D4 which is GIPO2
//thingspeak stuff
String apiKey = ""; // Enter your Write API key from ThingSpeak
const char* ssid = ""; // Enter your WiFi Network's SSID
const char* pass = ""; // Enter your WiFi Network's Password
const char* server = "api.thingspeak.com";
//You need three libraries, you can search for them on github
#include
#include
#include
// Data wire is connected to D4 on WeMos mini D1 which is really GPIO 2
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with a OneWire device
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);
//You need the address for your thermometer, each one is unique. Look under Dallas Temperature examples
//The sketch to find the address is called "one-wire search". They seem to start with 0x28, ...
DeviceAddress sensor1 = { 0x28,2,3,4,5,6,,7,8 };
DeviceAddress sensor2 = { 0x28,2,3,4,5,6,7,8};
//thingspeak stuff fire up
WiFiClient client;
void setup(void)
{
Serial.begin(9600);
sensors.begin();
Serial.println("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("This sketch is called Whatever you call it."); }
void loop(void)
{
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.print("Sensor 1: ");
//for my sensor1 the ice bath calibration revealed the thermometer read 0.6 degrees too high, I fix that here.
//You will have to test your thermometer to find the offset. Shave ice, wet it, stick the thermometer in the ice //Don't let it touch the walls. Use distilled water or reverse osmosis for the ice and water. Wait around 10 minutes //for it to stabilize. You can change the delay in the script and turn off deep sleep while doing calibration
Serial.print(sensors.getTempC(sensor1)-.6);
Serial.println( "C");
Serial.print("Sensor 2: ");
Serial.print(sensors.getTempC(sensor2));
Serial.println( "C");
if (client.connect(server,80)) // api.thingspeak.com
{
String postStr = apiKey;
postStr +="&field1=";
//
postStr += String((sensors.getTempC(sensor1)-.6));
postStr +="&field2=";
postStr += String((sensors.getTempC(sensor2)));
postStr += "\r\n\r\n";
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);
Serial.print("Refrigerator: ");
//here I'm sending the data to Thingspeak. I fixed the offset here, the 0.6 degree to high by subtracting 0.6.
Serial.print((sensors.getTempC(sensor1)-.6));
Serial.println(" C");
Serial.print("Freezer: ");
Serial.print((sensors.getTempC(sensor2)));
Serial.println(" C"); }
client.stop();
// thingspeak needs minimum 15 sec delay between updates,
delay(15000);
//If you are using battery or want to minimize power, you can use deep sleep.
//You have to connect a wire between rst pin and A0, but you can only do that after you have loaded the sketch
//I've learned, a few times, that a sketch won't upload if A0 and rst are connected. After the sketch is uploaded
//you can reconnect A0 and rst with a jumper wire.
//Deep sleep uses microseconds. One hour=36e8
ESP.deepSleep(36e8);
}
ThingSpeak and Twitter
You have to sign up for a free account with ThingSpeak. You can make your channel private or public. You need the same number of fields as thermometers. There are other instructables that detail how to set up a ThingSpeak channel.
You can do a lot with ThingSpeak, I've not explored all of the functions. What I did do was make a twitter account for the refrigerator and freezer and linked it to ThingSpeak. To set up ThingTweet alerts, go to "apps" and select ThingTweet. I then set up four alerts, one for when the refrigerator temp was greater than 8 C, a second for when it was less than 2 C, a third for when the freezer temp was greater than -15C and a fourth for when it was less than -25 C. When it goes out of range, I get a tweet sent to my twitter vaccine account which I've set up to give me a notification.
If a temp goes out of range, I can go to ThingSpeak and download my data and figure out how long it was out of range. You are suppose to call the Health Department if your vaccines go out of range, they will want to know what the max/min temp was and how long it sat out of range.
The calibration step is critical for these thermometers. You can watch a video on how to do it at...https://www.google.com/search?q=nist+ice+bath+cali...
I've had to include an offset for all but one of my thermometers.
If you need to make this portable you could hook up a cheap OLED screen, delete the ThingSpeak and Wifi parts of the sketch, and add the OLED library and lines to your sketch. A Lithium Iron Phosphate Battery...
https://www.amazon.com/gp/product/B07Y8M7686/ref=p... works well with the WeMos D1 mini.
The batteries need a special LiFePO4 charger. They fit in a AA battery holder, https://www.amazon.com/gp/product/B07QMQ5F21/ref=p...
but be careful, I made magic smoke when I put a big current drain on it doing a different project. I might have screwed up somehow shorting something out but I think the wires are pretty wimpy on this battery holder, since AA batteries are only 1.5 V not 3.3 V. I've not tested the oled with the battery and thermometer, I just had it connecting to WiFi.
You just solder the battery holder to your circuit board + and - rails and connect them with a jumper to 3.3V on the WeMos. You don't need a voltage regulator and nothing gets hot. They seem to only last about 24 hours when I had it connecting to the internet every 30 minutes, but I only tested it one day and night.
The Glycerin and Magnets
I wanted to be able to attach the circuit board to the side of the refrigerator. I just used some jumper wire to attach the magnets to the holes. I'm hoping to reuse this circuit when the pandemic is over for something else.
I finished off some shampoo from a hotel visit, (remember hotels?) and filled it with glycerin. The glycerin doesn't freeze in the freezer and moderates the temp of the probe to a similar degree as the liquid in the vaccine vials. That way when the door is opened, my alerts won't fire unless the door is left open.
I used a surgical glove, rubber bands and surgical tape to secure the thermometer in the bottle. It is leakproof today, but I attach the device inside the refrigerator so it doesn't fall over and make a mess. I've learned this the messy way.
The cables on the thermometers are really thick. They make a tolerable seal as is, but I decided to remove the black outer tubing so it fits in the door better. I've taped the three thin wires in place so they don't move when I open the door. I couldn't get a wifi signal when the device was in the freezer, so I leave the circuit board stuck on the outside of the unit.
I'm sure the people with 3D printers could make a far superior case. I used a blueberry container but the staff thought it was tacky.
Good luck with your vaccination program! Hit those deltoid muscles cells with your best shot!