Publish 1024 bytes limit

I feel like I am approaching this plaform in the wrong way, I have approxiamte 10 bytes of information I am trying to send to a lambda but if publish it the resulting data usage is 68 bytes.

I have two byte id and 8 bytes of data but I get charged for each character of my payload

[{"id":"c0401fe","data":["22","01","01","00","00","00","00","00"]}]

how do i avoid this?

Nothing is charged per byte, per se. In the normal case of using normal Particle primitives such as publish, subscribe, functions, and variables, the unit of measurement is a data operation. One Particle.publish is one data operation regardless of length.

On the free plan, there's no charge at all, though there's a limit to the number of data operations you can use in a month (720,000). You can also get enough cellular data that you should run out of data operations before you run out of cellular data in most cases.

Once you move past the free plan, the basic plan has blocks of data operations, cellular data, and devices. The number of blocks is determined by how much of each you use. See the data operations guide.

Things are a little more complicated if you bypass the Particle cloud on cellular devices, which we do not recommend. In this case, the cellular data will be the limiting factor, and using a protocol like TLS/SSL will likely cause you to use a significant amount of data, making it no longer cost-effective.

Sorry, not that I am billed by character just that the information I want to send is only 10bytes of actual information but it uses 64 character in the publish which just feels like I must be doing something wrong. It wouldn't really be an issue if it was billed purely by data usage but if I dont fully pack my publishes with info I wont ever utilize my data limit I would hit a publish limit before then. Eg if you publish 100,000 512 byte messages on the free plan you can never utilize all 100mb

The limit is the least of the data operations, maximum devices, and cellular data. While I can appreciate wanting to take advantage of the amount of cellular data available, the value is set to make sure you have enough for overhead and OTA transfers so you don't have to worry about the exact number of bytes you are using. Just keep track of the number of publishes you make, regardless of size.

Ok thanks

so i cant publish just the 10bytes of data it has to be stringified? this matters because i need to calculate how many measure i can put per publish

The publish data must be a string consisting of UTF-8 characters. It cannot be binary data. However it does not need to be JSON, so you can use a more compact text-based representation if you want.

One of the uses of Logic is to unpack data from an event into a format more usable by external services.

do you see this limitation of a particle platform changing in future? seems excessive to write your own encoder/decoder just to publish some info

Yes, larger, binary, and structured data publishes are possible in the future.

1 Like

Hey, you can grab any C or C++ base64 or base85 encoder and use it.
Cheers

1 Like

right but since the publish is represented as a string wouldnt that increase space because the legnth of the base 64 is represented as a string on particle side so each character of the base4 encodeding values is a byte