Showing posts with label DEFCON. Show all posts
Showing posts with label DEFCON. Show all posts

2023-01-11

Bluetooth Low Energy DEFCON

I have been meaning to get my head around Bluetooth for some time, and I think I have finally come up with a project idea which is a bit whacky, but I think should work.

I have discovered that Bluetooth Low Energy (BLE) is different from full bluetooth, something I had not realised, but that BLE should do what I want. The little ESP32 chips with which I am very familiar can do BLE, so this should be simple (LOL).

So here is the idea - DEFCON box. I have one of these at home :-

The way this works is that it shows a DEFCON level depending on who is in the house, so each of the kids has a level, and the lowest level shows. It beeps and the lights click as the go off and on to change levels. All good fun. We know who is about to open the door just before they do...

However, the way it actually works is quite complex. It works on WiFi and MQTT and is told by an MQTT command what level to show. The command comes from a FireBrick, which uses its profiles to decide what level applies. It does that based on the DHCP leases for people's phones on the WiFi. It is really quick to pick up people arriving, but takes the DHCP lease timeout to realise they have gone. But in spite of this complexity it works.

I did think it would make a fun present for someone, but the complexity of WiFi, MQTT, FireBrick and so on makes it really not simple to set up at all.

So this is where BLE comes in...

The idea is that it would scan for BLE devices and pick up phones being present directly. Of course BLE is designed to not allow you to track people, so needs a bit more, and it needs a simple way to tell it which phones are which DEFCON level.

The idea is a button, you press it, and press it repeatedly to pick a level that will flash. The device would be BLE discoverable so show on a phone, and the phone then connects and bonds with the DEFCON device. It then remembers the phone and the level. Because (I hope) the bonding will have an identity resolution key for the phone, it should be possible to passively scan and work out when each phone is present or not.

This makes for a really simple user interface - one button and bond from a phone.

Of course I may face issues with the libraries. A passive scan to find a device you know may not be possible as normally when found you connect to confirm the device is not a fluke random match (which, for this application I am not really too worried about). I'm also assuming a phone will tell my device a key for this - it may not, or may only if it thinks the device is something it expects to want to request a connection. But even so, I can try, and this should cover quite a lot of BLE learning.

So, watch this space :-)

Update1: Demo code works - but I need to advertise only when adding a phone, and as something an iPhone would want to connect to, this was pair using a BLE app not the main settings menu. And I need to work out scanning. Much to do.



2021-10-31

DEFCON Lights

A bit of fun for a change... 

Firstly, seeing as even some of my geeky mates did not know this, the US has a DEFCON level (defence condition). See wikipedia for more. There are images of DEFCON lights in a variety of films/shows (including War games, and Stargate). DEFCON 1 is most severe.

I saw RS did some rather nice 12V LED indicators, which I was using for a different projects, and realised they would make quite nice DEFCON lights.

So the shopping list:-

  • RS 791-8579 White
  • RS 791-8573 Red
  • RS 791-8589 Yellow
  • RS 791-8582 Green
  • RS 791-8585 Blue
  • RS 877-1836 Sounder
  • Amazon relay board
  • Amazon box
  • Some wire and Wagos, and I have a 12V supply in the house.

The relay board is simple, ESP12-F based (ESP8266), so flashed with Tasmota and configured the relays 1 to 8. Note these are not ideal boards as they have ground plane around the antenna. I may have to make a relay board some time for a different project that needs 9 relays, but this was fine for this fun project.

The LED modules are simple enough to wire up. As is the sounder.

The result all connects to an MQTT server over WiFi. The relays are set up on tasmota, but relay 8 (the sounder) has a pulse time set (1 second) so I can simply turn it on to make a beep. I did consider a flashing strobe light as well, but meh...

The next challenge was to work out how to drive it sensibly. Setting a light was simple, I did a cmnd/DEFCON/Backlog Power0 0;Power3 1;Power8 1 for example. This turns all lights off, turns on light 3, and makes the sounder beep for a second.

I use a FireBrick as the MQTT server, so I created some profiles for DEFCON 1 to 5. Each is testing if DHCP is active for some IPs on the WiFi, and if the higher levels are all off so only one at a time. They then have that backlog command as the "on" MQTT command with retain.

This means that I get a DEFCON depending on who is in the house. DEFCON 1 for presence of the those who shall not be named (anti-vax). Cool or what?

P.S. I am sure Letraset used to be a thing - finding transfer numbers was not easy...

QR abuse...

I'm known for QR code stuff, and my library, but I have done some abuse of them for fun - I did round pixels  rather than rectangular, f...