Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
projects:cyberalarm [2019/11/23 00:16] – [The Button] kratenkoprojects:cyberalarm [2019/11/23 21:09] kratenko
Line 1: Line 1:
-====== Cyber Alarm ====== +~~NOTOC~~ 
-**In case of cyber, press button!**+====== Cyber Alarm====== 
 +<WRAP column 47%> 
 +{{ :projects:incaseofcyber.png?nolink&300 |}} 
 +</WRAP> 
 +<WRAP column 48%> 
 +{{ :projects:button-free.png?nolink&300 |}} 
 +</WRAP> 
 +<WRAP clear></WRAP>
  
 <markdown> <markdown>
-# The Button +The modern world is a busy place and not without danger. Computers are part of every aspect of our lives, and global networks connect them all around the planet. In this world, the threat of *cyber* is ubiquitous at every given moment. 
 + 
 +To stand a chance in face of thees dangers, you need a way to react in those situations. That is why you should always  
 +carry with you a **Cyber Alarm Button**! 
 + 
 +The *deep cyber* **Cyber Alarm Button** sends out an alert message with the simple push of a button. Your emergency situation is  
 +communicated using high tech long range transmission technology from a low power, long life, battery powered, water prove (IP67) alert device. Also it is big and red. 
 + 
 +A Big Red Button 
 +The Cyber Alarm is a very basic LoRaWAN show case device. It is operated by a simple Arduino using a pre-existing LoRaWAN library, so only very few code adjustments had to be added to the example sketch. Transmission is triggered by an interrupt that is triggered with a push button on a GPIO of the Arduino. It consists of only very few hardware parts and besides the LoRaWAN-module they are all pretty basic. The device is powered by two normal AA batteries. 
 + 
 +As a blueprint for this project (assembling and Arduino programming) I used a story about a GPS tracker by [Marco Rudolph](https://www.thethingsnetwork.org/u/IoT_Marco) posted on The Things Network: 
 +https://www.thethingsnetwork.org/labs/story/lorawan-gsp-tracker 
 + 
 +## LoRaWAN 
 +LoRaWAN is a long range radio communication technology that is optimised for low power devices. The tradeoff is a very limited data rate (we are talking bytes here, not kilobytes). It uses only publicly available frequencies, and you can (and often must) build your own network by setting up Gateways that connect to the internet. There exists a community called *The Things Network* that is building a free and open LoRaWAN network for everyone to use. Think freifunk for devices. If you want to learn more you can scroll to the bottom of this page; you will find the recording of a talk at 35c3 where we gave a short introduction to LoRaWAN. 
 + 
 +## The parts 
 +</markdown>{{ :projects:button-parts.jpg?nolink |}}<markdown> 
 +What you see in the picture is all that is needed: 
 + 
 +* 1x Arduino Nano 
 +* 1x RFM95W 
 +* 1x Button (AS22-FAK542-Y IP67) 
 +* 1x Battery holder, 2xAA 
 +* 2x AA battery 
 + 
 +Well, besides a whole bunch of wires and a bit of soldering tin, of course. 
 + 
 +With the model I chose, the button did cost about twice as much as all the other parts combined. But then again I am using the button also as the case. And it is big and red. The other parts cost me about 10€. So yeah, the button costs about 30€. 
 + 
 +*A note on voltage*<br> 
 +Using an Arduino Nano is not the perfect choice. The sx1272 module runs on 3.3V, the Arduino normally runs on 5V. That voltage can destroy the sx. A 3.3V current is provided by the Arduino, but the GPIOs operate on 5V. I am using 2 AA batteries with 1.5V (a bit higher actually, when full, so I get about 3.4V from them). It is absolutely possible to operate an Arduino Nano on that voltage, and it will have that lower voltage on its GPIOs as well. But you will have a problem when you want to program your Arduino, as the USB connection will provide 5V to it. When you have your parts soldered together already, you might have a problem. You can solve this by adding a logic shifter, but that will increase power consumption. Another solution is to use a 3.3V operated Arduino (those exist, but I did not have one around when I started building). 
 + 
 +## Assembling the parts 
 +</markdown>{{ :projects:button-attached.jpg)?nolink |}}<markdown> 
 + 
 +Because of the voltage differences it is important to program the Arduino before the soldering is done. While I did the development I kept the parts on a breadboard, so I could add a logic shifter. The final soldering was done when I was content that my programming would work. 
 + 
 +There are surprisingly man connections between the Arduino and the RFM95W: 
 + 
 +    Arduino VCC  -- 3.3V RFM95W 
 +    Arduino GND  --  GND RFM95W 
 +    Arduino D4   -- DIO0 RFM95W  
 +    Arduino D5   -- DIO1 RFM95W    
 +    Arduino D6   -- DIO5 RFM95W  
 +    Arduino D7   -- DIO2 RFM95W  
 +    Arduino D10  --  NSS RFM95W 
 +    Arduino MOSI -- MOSI RFM95W 
 +    Arduino MISO -- MISO RFM95W 
 +    Arduino CLK  --  SCK RFM95W 
 + 
 +Be sure to use the 5V pin on the Arduino and not the 3.3V when doing the final connection, because we are using only 3.3V to power the Arduino via the 5V pin. We also connect the other  
 + 
 +    Arduino 5V   -- Battery VCC 
 +    Arduino GND  -- Battery GND 
 +    Arduino GND  -- Button P0 
 +    Arduino D4   -- Button P1 
 +     
 +Finally we attach a wire to the ANA pin of the RFM95W. That will be our antenna (we could really improve reception with a tuned antenna, but this works quite well). 
 + 
 +As you can see, I was able to fit all parts inside the button's case. I had to remove one of the internal switching elements (the button has a closing and an opening component). 
 + 
 +## Arduino Firmware
 Arduino Sketch: https://github.com/deepestcyber/cyberalarm-button Arduino Sketch: https://github.com/deepestcyber/cyberalarm-button
  
-# Presentation at 35c3+The LoRaWAN framework used in the sketch does quite a lot in the background. LoRaWAN requires a lot of states and timing, so it includes a kind of RTOS. This can be a bit confusing if you are not used to it. You can just use the link sketch and adjust `DevEUI`, `AppEUI`, and `AppKey`. We get those value from TTN.
  
-<iframe width="1024" height="576" src="https://media.ccc.de/v/35c3chaoswest-27-long-range-radio-communication-for-everyone-using-lorawan-/oembed" frameborder="0" allowfullscreen></iframe>+The device sends a single byte on port 23, where the byte indicates the severity of the alarm.
  
-https://media.ccc.de/v/35c3chaoswest-27-long-range-radio-communication-for-everyone-using-lorawan-+## Going low power 
 +We want the batteries to last as long as possibleMost of the time, our device does nothing but sleep in a power saving spaceIt waits for an interrupt on the GPIO connected to the button. You have to tweak your Arduino quite a bit to get it power saving. On the software side you need to enable the low power mode. You will also take care of your pins so that none keep in a state that leaks power.
  
-</markdown>+There are some hardware components on the Arduino that we do not need but cannot turn of and that will consume power. The most obvious one is the LED that is permanently on. You can easily break it off with screw driver or better yet solder it of. The next thing is the voltage converter that is supposed to generate 5V out of a higher voltage. We do not use it, but it still uses power from the power that enters through its output. So we solder that off, too. There is still the USB controller used to program the Arduino. We could also take that of to save even more power, but then we would not be able to change the firmware. Also it would be strange to use an Arduino at this point, as we would have not much left but the Atmel µC. At this point we should probably start from the Atmel only and use an external programmer &ndash; but that would be beyond the scope of this. 
 + 
 +## The Things Network 
 +We created an application `cyber-alarm` in [The Things Network](https://thethingsnetwork.org), so that our device can send messages whenever there is TTN coverage. To keep things easy, we are using Activation By Personalization (ABP). 
 + 
 +## Backend 
 +A website integrated into TTN via HTTPS. All activations of the button are sent to the backend end will be listed there. <br> 
 +https://alarm.deepcyber.de 
 + 
 +## MQTT 
 +We also created a MQTT integration on TTN, so you can easily subscribe to Cyber Alarm Events. This can be done with a RaspberryPi that triggers some visual or accustical alarm signal. You can also do this from your PC to trigger some event on your desktop. 
 + 
 +TODO: supply key for subscribing to publisher 
 + 
 +# Your own Cyber Alarm 
 +This article and the Arduino sketch should provide enough information to build your own LoRaWAN Cyber Alarm. If you want to connect it to our Application, you can contact us. Try on Mastodon: https://chaos.social/@deepcyber &ndash; or you will find contact information somewhere on our site for sure. 
 + 
 +# Presentation at 35c3 
 +The Cyber Alarm was used in a talk about LoRaWAN that we were able to hold at 35c3 &ndash; thanks to Chaos West for hosting us on their stage! Sadly, the first few minutes of the recording are audio only. But the Cyber Alarm can be seen.<br> 
 +https://media.ccc.de/v/35c3chaoswest-27-long-range-radio-communication-for-everyone-using-lorawan- 
 +</markdown><html> 
 +<iframe width="840" height="473" src="https://media.ccc.de/v/35c3chaoswest-27-long-range-radio-communication-for-everyone-using-lorawan-/oembed" frameborder="0" allowfullscreen></iframe> 
 +</html>