DW1000 = The radio chip on its own, not what you linked to.
DWM1000 = A module containing a DW1000 chip, antenna, clock and a few other parts needed to make the DW1000 hardware work.
Both give an SPI interface for the software to configure and drive the chip. You will need to configure and drive them appropriately but that would be the same even if you used identical hardware.
The link you have as DW1000 looks like it’s actually some third party copy of a DWM1000 attached to the processor board. Either way they should be compatible.
The only thing to double check is which bands the antennas support. The DWM1000 antenna is good for any of the supported radio bands, the link you gave for “DW1000” doesn’t indicate clearly if their antenna design is good for both bands or just one.
That depends on the mode it’s in, receive enabled but nothing to receive, idle or sleep. The data sheet will give you power consumption numbers for each mode.
If the chip is doing nothing - you’ve initialised it, configured the radio etc… but not enabled receive then it’s the IDLE mode number, 13.4 mA.
If you’ve enabled receive and it’s listening for a signal but there is nothing there so it sits listening then it’s RX, 160 mA. This is why there is an option for a receive timeout, in battery powered modes you don’t want to sit in this state for a long time if there is nothing to hear.
If you put it onto sleep mode then it’s 3.5 mA but you will need to wake it from that mode, which takes a short while because the PLL will need to restart, before you can do anything else.
You can see that in the loop it has: DW1000Ranging.loop();
Is there a way to turn it off when I’m not using it? So that it consumes 3.5mA. It occurs to me to place a conditional in the loop to disable the DW1000Ranging.loop(); when I press the button. What do you think?
I used the library and it works fine, but that code that I sent you with DW1000Ranging.loop(); it is always waiting to receive data. That is, it always consumes 160mA.
However, in case I don’t want to use a sleep function as such, I just remove DW1000Ranging.loop(); as you say, so that he stops expecting to receive information, right? Do you think it will work?
It depends on the state DW1000Ranging.loop() leaves the part in when it exits. You may need to put something like a command to return to idle where you have the print “Waiting”.
An arduino forum is probably more appropriate for how best to implement this since it’s a code structure and library issue rather than anything to do with the DW1000 itself. If nothing else it’ll have more people on, this isn’t exactly a high traffic board.
If you remove the first loop() then loop is only called when serial data is entered.
Try something more like
bool sleepMode = false;
void loop() {
if (!sleepMode)
DW1000Ranging.loop();
if (Serial.available()) {
int state = Serial.parseInt();
if (state == 1) {
sleepMode = false;
DW1000.spiWakeup();
// don't know if some other re-initialisation will also be required here or not.
// maybe try a short wait and then soft reset if it doesn't work as is.
Serial.println("ON");
}
if (state == 2) {
sleepMode = true;
DW1000.deepSleep();
Serial.println("OFF");
}
}
}
It tells me that the error is when I press 2. Because at first it did work.
3nd test without DW1000.deepSleep();:
If I remove DW1000.deepSleep(); it works. That is, it turns the loop on and off. My question is: is it actually sleeping or not? Does it still consume 160mAh?
void loop() {
if (!sleepMode) {
DW1000Ranging.loop();
}
if (Serial.available()) {
int state = Serial.parseInt();
if (state == 1) {
sleepMode = false;
Serial.println("ON");
}
if (state == 2) {
sleepMode = true;
Serial.println("OFF");
}
}
}
If you remove the sleep command or start with sleepMode = false; then the module isn’t sleeping, all that’s happening is that you’re not calling the loop function. If you’re not calling the loop function then it’s not going to output a range no matter what power mode the part is in.
As I said, you may need to do some re-initialisation after waking from sleep. This will depend on the library. Currently the only times it’s working are when you’ve never put it to sleep.
If you want to know how much power it’s using then measure the power usage. You can’t guess that sort of thing, you need to measure it just like you would the power consumption for any other part.