Sometimes your mistakes are so simple, you can’t find the answers on the internet…
Yeah... so after I put the SD card into the raspberry pi, it worked. I then went on to make several more mistakes on the same level, but eventually I figured them out as well.
Let’s get into the progress I’ve made and what I learned. This week I worked on getting the toaster oven control done. I decided to use a thermistor to measure the oven temperature. I have never done anything with thermistors before, and this article https://learn.adafruit.com/thermistor/using-a-thermistor was very helpful to me. It seemed good practice to use an NTC type for my application and I chose the 103JG1K thermistor. It’s a 10K ohm thermistor and I connected it in a simple voltage divider with a 10k ohm resistor like they did in the article.
Since the raspberry pi doesn’t have a built in ADC, I used the MCP3008. This chip uses SPI communication. I’ve always been too intimidated to learn how to actually use SPI, but it turned out to be SUPER simple. I read a bunch of stuff on using SPI communication and this article https://learn.adafruit.com/raspberry-pi-analog-to-digital-converters/mcp3008 explained how to use the MCP3008 really well. I was nervous about being able to still use the touch screen display, but I found that the raspberry pi actually has two channels. To access the second channel I just had to connect to the CE1 pin instead of the CE0 pin, which the touch screen uses. I tested the ADC using the sample code provided in the MCP3008 library and then wrote my own code to calculate the actual temperature from the thermistor. I haven’t really used python before and it took me a long time to figure out how to get it to do my equations with floating point numbers instead of integers. I verified that it worked at room temperature and by touching it to a frozen block of cheese.
I’ll attach my code at the bottom.
For the toaster oven control, I built a mains power switching circuit on a solderable breadboard.
It uses the H11AA1H11AA1 optocoupler for zero crossing detection and the MOC3010 and BT136 Triac for the actual power switching In my previous post I wrote about testing the zero cross detection part of the circuit with the Arduino Trying to get that to work on the raspberry pi though was very difficult I found how to do GPIO interrupts easily enough but it took a few days to discover that you can’t just simply do an interrupt service routine with a timer on the raspberry pi That’s because it’s running like a computer with a full operating system If it were a microcontroller like the Arduino it would easily run timer interrupts This really opened my understanding to the different capacity and uses for the two types of controllers Now I understand why so many of the other projects are using voice control and internet and inter-connecting systems The raspberry pi is naturally a device to use for IoT projects
Finally, I decided that rather than spend another one or two weeks trying to get true AC phase control, I’ll just do a bang-bang type of controller. Instead of actually using the zero cross detector to control how much power my circuit is outputting, I’ll just turn on the triac for a few minutes at a time and turn it off when the oven reaches a certain temperature. My code ended up being reduced to just a few lines. If I have time later on, I’ll come back to this and probably get it working with an Arduino and have the Arduino and raspberry pi communicate over a serial line.
When I went to put the whole thing together and actually turn on the oven, I realized that because my thermistor is just a little glass bead with two little wire leads sticking out of it, I couldn’t just stick it in my toaster oven. I’ll need some heat resistant wire to allow it to be in the oven measuring temperature and attaching to the raspberry pi, then I can finish the oven control.
Now I need to get to work on the platform and roller.
(Code is now attached)
Top Comments