杏吧原创

How to make a BBQ thermometer with a BBC micro:bit

With a BBC micro:bit and a temperature sensor, you can make a device that tells you when your food is perfectly cooked

barbecue

BARBECUES are a great joy of the outdoors 鈥 but undercooked food isn鈥檛. So let鈥檚 make our own digital temperature sensor to check both coals and food are piping hot.

The BBC micro:bit has a built-in temperature sensor, but we will use a DS18B20 temperature probe instead. This is more accurate and more flexible 鈥 we can even poke it into food (just check the coating of your sensor is food-safe).

The sensor has three wires: black, yellow and red. Slot each into a different row on your breadboard, then use a crocodile clip jumper wire to connect the black wire to the micro:bit鈥檚 ground. We will need a resistor to help it talk to the micro:bit. Place your 4700 ohm resistor so that one leg shares a row with the yellow wire, and the other leg with the red. Connect the row with the yellow wire to micro:bit鈥檚 pin 0, and the row with the red to 3V.

Let鈥檚 add an LED to alert us when we reach the desired temperature. Connect the LED鈥檚 short leg to micro:bit鈥檚 ground, and the longer leg to one end of a 470 ohm resistor. The other end should go to pin 1, so the resistor stops the LED drawing too much current.

Now to teach our micro:bit some new tricks. In the MakeCode editor, go to 鈥淎dvanced鈥, then click on 鈥淓xtensions鈥. In the search box, enter 鈥淒FRobot/pxt-ds18b20鈥. Clicking on the result will cause an option called 鈥淒S18B20鈥 to appear in the editor menu. We have just added some code to help us read the sensor more easily, just like a programmer uses a pre-existing 鈥渓ibrary鈥 to add functions to their programs without having to write all the code themselves.

Grab a 鈥渟how number鈥 from 鈥淏asic鈥 and clip into 鈥渇orever鈥. Clip into that a 鈥渞ound鈥 block from 鈥淢ath鈥 and, from 鈥淒S18B20鈥, a 鈥淧in 0 Temperature_number鈥. This will show the temperature as a whole number on the micro:bit screen.

Now for the alert. From 鈥淟ogic鈥, take an 鈥渋f/else鈥 block and clip into it a 鈥0 \> 0鈥 comparison. Clip another 鈥減in 0 Temperature_number鈥 on the left-hand side of the comparison, and write a value on the other. This is your target temperature 鈥 whatever you want the coals or the food to be.

Nestled under 鈥渋f鈥 add a 鈥渄igital write pin 1鈥 from 鈥淧ins鈥 and type 1 in the box. Put another under 鈥渆lse鈥, but leave the default zero. This turns the LED on and off as the temperature goes above and below the target. As ever, you can .

Finally, some safety frills. To keep the sensor cable away from the coals, I bent a wire coat hanger into a stand. For extra heat protection, I padded the wire with swatches clipped from oven mitts.

Now go forth and cook. Just don鈥檛 forget to change the target temperature between checking the BBQ and food, or you will end up with very well-done wings!


New stuff you need


Next in the series

1 Moisture-sensing plant

2 Moisture and temperature-sensing plant

3 Plant auto-waterer

4 Tweeting wildlife cam

5 Pest scarer

6 BBQ thermometer

7 Rain alarm Tell if precipitation is on the way

8 Mini weather station

9 & 10 Remote controlled pest-proof bird feeder parts 1&2

To download a printable version of this page click here

Email:maker@newscientist.com

Topics: Electronics / Food and drink