If you want to learn how to build other types of devices with Azure IoT and a Raspberry Pi check out this awesome simiulator which integrated with Azure IoT Service in real time. Raspberry Pi Azure IoT Online Simulator
I really wanted to make this device look like the bat phone from the 60's. I spend a lot of time at antique shops looks for old "direct" phone like you would use in a factory to call a specific location. Finally on one of my trips to Hocking Hills I found one. I wanted the device to ring and blink like the original so I wired up all up on a solder free breadboard. I first used a larger breadboard for testing them moved everything to a smaller one that installed inside the phone with double sided tape. I also spend a lot of time with Red Apple colordered spray paint.
The following articles helped me figure out the LED and buzzer elements:
- Turning on an LED with your Raspberry Pi's GPIO Pins
- HOW TO USE an LED with Raspberry Pi
- Buzzer on Raspberry Pi generating beeps
Here is the pinout from the Raspberry Pi
Final smaller breadboard installed inside phone
Overall view of the inside after installation was complete
I used the scripted install to add .Net core onto the Raspberry Pi devices. Scripted Install
Download the files onto the device using wget
'''wget https://dot.net/v1/dotnet-install.sh'''
Run the following command from the terminal.
'''sudo bash dotnet-install.sh -c Current -InstallDir $HOME/.dotnet'''
This will ensure that every time you open a bash terminal dotnet will be available.
'''printf '\nexport DOTNET_ROOT=$HOME/.dotnet' >> .bashrc'''
'''printf '\nexport PATH=$PATH:$HOME/.dotnet' >> .bashrc'''
*NOTE: it is important to use the single quotes around these otherwise the variables will be expanded within the text file.
If you want to check to make sure the file was updated correctly you can run the following Cat .bashrc
In order for the device to connect to Azure IoT central and listen for commands we need to create a service that runs on the Pi and is actively listenting. Details for enabling this service can be found in the How to Deploy section, here we will walk through the settings in the service file and where to get those values.
Additional references: Tutorial: Create and connect a client application to your Azure IoT Central application
-Create a deployment folder on the Raspberry Pi
sudo mkdir /srv/PowerPhone
-Ensure your user owns the folder
sudo chown pi /srv/PowerPhone
-From the project folder run this command to publish the app self contained for linux. This will ensure all the depdencies are included for the linux platform.
dotnet publish -c Release -o /srv/PowerPhone -r linux-arm
-Open the PiService/PowerPhone.service file -Update the environment variables to match your device -Copy the file to the /lib/systemd/system
sudo cp /home/pi/IoTPowerPhone/PowerPhone/PiService/PowerPhone.service /lib/systemd/system
-Start the service and make sure there are no errors
sudo systemctl start PowerPhone
-Ensure that the service starts up on every reboot.
sudo systemctl enable PowerPhone
I also created a simple power app that would allow me to ring the phone manually. The call to the device is done through Power Automate using the Azure IoT Central connector.
-First create a simple Canvas app with a button.
-Create a new Power Automate Flow which will be run when the button is clicked. Because the command I created is within the "Ringer" component of the devices, I chose the Run a component command activity.
-Configure the activity based on your settings. The Device Id should match the device name you used in the PowerPhone.Service file.